DEV Community đŸ‘©â€đŸ’»đŸ‘šâ€đŸ’»

éœŠè—€æ•Šćż—
éœŠè—€æ•Šćż—

Posted on

Similar thing, not same

Common Lisp has do syntax. And Scheme too.

They have same form, but different semantic.

;; Common Lisp
(do ((i 0 (+ i 1))
     (j '() (cons (lambda()i) j)))
    ((= i 3)
     (mapcar (lambda(x)(funcall x)) j)))
;; → (3 3 3)
Enter fullscreen mode Exit fullscreen mode
;; Scheme
(do ((i 0 (+ i 1))
     (j '() (cons (lambda()i) j)))
    ((= i 3)
     (map (lambda(x)(x)) j)))
;; → (2 1 0)
Enter fullscreen mode Exit fullscreen mode

Scheme's do make a new location every time for each loop. Common Lisp is not so.

Top comments (0)

🌚 Browsing with dark mode makes you a better developer by a factor of exactly 40.

It's a scientific fact.