Guest User

Untitled

a guest
May 26th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. ;; dotimes
  2.  
  3. (define-syntax dotimes
  4. (syntax-rules ()
  5. ((_ n body ...)
  6. (let loop ((i n))
  7. (when (< 0 i)
  8. body ...
  9. (loop (- i 1)))))))
  10.  
  11. (dotimes 5 (print 1))
  12.  
  13. (define i 10)
  14. (dotimes 5 (print (set! i (+ i 1))))
  15. ;; 11
  16. ;; 12
  17. ;; 13
  18. ;; 14
  19. ;; 15
  20.  
  21.  
  22. (macroexpand-1 '(dotimes 5 (print (set! i (+ i 1)))))
  23. ;; (#<identifier user#let> #0=#<identifier user#loop>
  24. ;; ((#1=#<identifier user#i> 5))
  25. ;; (#<identifier user#when>
  26. ;; (#<identifier user#<> 0 #1#)
  27. ;; (print (set! i (+ i 1)))
  28. ;; (#0# (#<identifier user#-> #1# 1))))
Add Comment
Please, Sign In to add comment