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 -

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

c# - Search and Add Comment with OpenXML for Word -