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?

iterate:

prelude> let f x = (x + 2) * 10 in take 5 $ iterate f 1 [1,30,320,3220,32220] 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -