I want to define an infinite list where each element is a function of all the previous elements.
So, the n+1
th element of the list would be f [x1, x2, ..., xn]
.
This seems simple, but I cannot seem to get my head around how to do it. Can anyone help?
gen f = xs where xs = map f $ inits xs
Or
gen f = fix $ map f . inits
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With