Why is lazy evaluation in Haskell "not being lazy"? -


when tried following code in cghi:

take 1 $ take 1 $ repeat [1..] 

i expecting result of 1 instead of [[1,2,3,4,5,6,7,8,9,10,... printing on terminal.

why lazy evaluation not functioning i'm hoping under such situation?

take of type int -> [a] -> [a], i.e. returns list. seems you’re looking head, returns 1 element.

head $ head $ repeat [1..] 

Comments

Popular posts from this blog

gcc - MinGW's ld cannot perform PE operations on non PE output file -

How to connect android app to App engine -

hadoop - Running Map Reduce Job shows error - Mkdirs failed to create /var/folders/ -