Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foo = function(a,b) {a+b}
- x = 1
- n = 4
- out = vector("numeric")
- steps = seq(1, 4, by = 1)
- for( b in steps){
- ## initial value
- if (length(out) == 0){
- out = append(out, values = foo(x, b) )
- }else{
- out = append(out, values = foo( tail( out, 1), b) )
- }
- }
- tail(out, 1)
- foo_n <- reduce(map(1:n, ~partial(foo, b=.x)), compose)
Add Comment
Please, Sign In to add comment