Guest User

Untitled

a guest
Nov 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. foo = function(a,b) {a+b}
  2.  
  3. x = 1
  4. n = 4
  5.  
  6. out = vector("numeric")
  7. steps = seq(1, 4, by = 1)
  8.  
  9. for( b in steps){
  10. ## initial value
  11. if (length(out) == 0){
  12.  
  13. out = append(out, values = foo(x, b) )
  14. }else{
  15.  
  16. out = append(out, values = foo( tail( out, 1), b) )
  17. }
  18.  
  19. }
  20. tail(out, 1)
  21.  
  22. foo_n <- reduce(map(1:n, ~partial(foo, b=.x)), compose)
Add Comment
Please, Sign In to add comment