haskell - Dynamically create list with function -
my goal create infinite list applying function last element. example if begin list looks like
[1]
and apply function f(x) = (x + 2) * 10, should end with
[1, 30, 320, 3220, 32220...]
how code in haskell?
prelude> let f x = (x + 2) * 10 in take 5 $ iterate f 1 [1,30,320,3220,32220]
Comments
Post a Comment