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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -