[Haskell-cafe] swap a pair of integers

David House dmhouse at gmail.com
Mon May 29 16:28:43 EDT 2006


This was originally, and accidentally, sent to just Jenny, and not the list.

On 29/05/06, Jenny678 <mestor1 at gmx.de> wrote:
> hello,
> i want swap a pair of integers
> for example
> Main> 17
> out> 71
> Can somebody help me?

When you want to do manipulation on the digits of a number like this,
normally the easiest thing to do is to convert it to a string, use
list manipulation functions, then convert back to an integer.

For example:

Prelude> (read . reverse . show) 17
71

--
-David House, dmhouse at gmail.com


More information about the Haskell-Cafe mailing list