13 Feb
2021
13 Feb
'21
7:01 a.m.
I'm looking at this <https://stackoverflow.com/questions/23768413/building-a-list-from-left-to-right-in-haskell-without> from Stackoverflow and wondering what is meant in the accepted answer when he says *In Haskell you can safely do recursive calls inside lazy data constructors, and there will be no risk of stack overflow or divergence. Placing the recursive call inside a constructor eliminates the need for an accumulator, and the order of elements in the list will also correspond to the order in which they are computed*: collatz :: Integer -> [Integer] collatz n | n <= 1 = [] collatz n = n : collatz next where next = if even n then div n 2 else n * 3 + 1 What is meant by lazy data constructor in this context? LB