[Haskell-beginners] Concatenating lists

Lorenzo Bolla lbolla at gmail.com
Thu Mar 22 16:05:43 CET 2012


On Thu, Mar 22, 2012 at 2:44 PM, Jan Erik Moström <lists at mostrom.pp.se>wrote:

> Hi,
>
> I've just started to learn Haskell and played around a bit and tried this
>
> 1: let x = [1,2,3]
> 2: let x = x ++ [4,5,6]
> 3: x
>
> The last line doesn't give a result. I assume that this is because 'x' is
> a name of a value, in the second line I redefine 'x' to a new value but
> Haskell doesn't evaluate the value until the last line but then 'x' becomes
> recursively defined in itself (the second x on line 2 is interpreted to
> refer to the value of the first x on line 2 and  not the value defined in
> line 1). This behavior is caused by the lazy evaluation in Haskell.
>
> Have I understood this correctly?
>

Yes.




>
> - jem
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120322/63bb1e37/attachment.htm>


More information about the Beginners mailing list