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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -