Re: determining if a int is a power

2003-11-09 Thread Matt Harden
On Saturday 08 November 2003 04:31 am, Wolfgang Jeltsch wrote: > Am Samstag, 8. November 2003, 00:22 schrieb Hamilton Richards: > > Also note that > > > > if x then True else False > > > > is just a verbose way of writing > > > > x > > Actually, it's just a verbose way of writing x `seq` x,

Re: Converting IO Int --> Int

2003-11-09 Thread Jad Saklawi
Am new to haskell, however is this what you mean : num <- getLine let x = read num :: Int -- ?? Greets, Jad Saklawi Tim Stitt wrote: Can anyone tell me how to convert a value of type IO Int to a value of type Int. I wrote a simple script to read an integer from the u

Beta Reduction, undefined vs Type Classes

2003-11-09 Thread Jared Warren
Consider: > class Thing t where > thing :: t > > instance Thing Int where > thing = 0 > > instance Thing Char where > thing = 'a' Can someone please explain why > fst (1,thing) ...gets an 'ambiguous type variable' error, but > fst (1,undefined) ...doesn't? And is there anything I can ch

Converting IO Int --> Int

2003-11-09 Thread Tom Pledger
Tim Stitt writes: | Can anyone tell me how to convert a value of type IO Int to a value of type | Int. | | I wrote a simple script to read an integer from the user using IO and then | the value is returned from the IO function using | | return value | | with a return type of IO Int. |

Converting IO Int --> Int

2003-11-09 Thread Tim Stitt
Can anyone tell me how to convert a value of type IO Int to a value of type Int. I wrote a simple script to read an integer from the user using IO and then the value is returned from the IO function using return value with a return type of IO Int. In the calling function I wish to do a compari

Re: determining if a int is a power

2003-11-09 Thread Graham Klyne
It seems to me that a neater approach might be to create a list of powers (squares) and see if it has any members in common with the list supplied. Of course you have to deal with the issue of not knowing in advance how many members of the list of squares will be needed... which can lead to usi