[Haskell-beginners] question about comprehension or array creation

cchang djvsrose at gmail.com
Sat Jan 15 15:19:05 CET 2011


Hi,

I tried to create an array like the following.

"array (1,3) [(1,1), (2,2), (3,3)]"

through code in .hs
e = [1,2,3]
array (1,3) [(i,v) | i<-[1..3], v<-e]

but I got
"array (1,3) [(1,3), (2,3), (3,3)]"

why v is always 3 in this case? Can anyone shed some light on this?

Thanks,





More information about the Beginners mailing list