brandizzi

Lazy evaluation in R

Jul 23rd, 2014
259
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. f <- function(a, b) {
  2.   print('1st value will be printed')
  3.   print(a)
  4. }
  5.  
  6. f(2, print('ok'))
  7. # Output:
  8. # [1] "1st value will be printed"
  9. # [1] 2
  10.  
  11. f(print('ok'), 2)
  12. # Output:
  13. # [1] "1st value will be printed"
  14. # [1] "ok"
  15. # [1] "ok"
RAW Paste Data