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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -