LARA

Examples of Lazy Evaluation

Example 1

evenNats = 0 : (map (+2) evenNats)
firstTen = take 10 evenNats
Hugs> :load /home/kuncak/lecture15/evenNats.hs
Main> firstTen
[0,2,4,6,8,10,12,14,16,18]
Main>

Example 2

ite c x y = if c then x else y
test q = ite (q == 0) 100 (1.0 / q)
v = test 0

More at