Given a vector v and fn f, how do I generate the matrix {v, f(v), f(f(v)), … f^k(v)}?
I have a vector x
and a function f
. I need to generate the matrix whose first column is v
, second column is f(v)
, and so on up to the final column f^k(v)
. In a functional language I could use an unfold operation. I’ve had a look at the purrr
cheatsheet, but I can’t spot any analogue.
Given a vector v and fn f, how do I generate the matrix {v, f(v), f(f(v)), … f^k(v)}?
I have a vector x
and a function f
. I need to generate the matrix whose first column is v
, second column is f(v)
, and so on up to the final column f^k(v)
. In a functional language I could use an unfold operation. I’ve had a look at the purrr
cheatsheet, but I can’t spot any analogue.