
12 Feb
2021
12 Feb
'21
6:01 p.m.
I'm looking at this https://stackoverflow.com/questions/23768413/building-a-list-from-left-to-ri... 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