[Haskell-beginners] question

Adrien Haxaire adrien at adrienhaxaire.org
Wed Jul 13 22:00:40 CEST 2011


Le 13/07/2011 21:27, Roelof Wobben a écrit :
> For a exercise I need to multiply a number by itself.
>
> So I used :
>
>
>
> [x^2 | x<- [1..100]]
>
> but now I get a error message on codepad that ^is unknown.
> What can I use then and where do I find it on a keyboard?
>
> Roelof

Hello,

What does codepad not recognize? the caret character or the expression 
you used?

ghci 7.0.3 gives me this:

Prelude> [x**2 | x <- [1..10]]
[1.0,4.0,9.0,16.0,25.0,36.0,49.0,64.0,81.0,100.0]

Prelude> [x^2 | x <- [1..10]]
[1,4,9,16,25,36,49,64,81,100]

Did you try it on ghci or in a text file?

I guess we need more details if the former. Which version of ghci do you 
have? What is your OS?

Regards,
Adrien



More information about the Beginners mailing list