Advertisement
Guest User

Untitled

a guest
Mar 18th, 2022
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.84 KB | None | 0 0
  1. (labels ((mapatoms (function tree)
  2.            (cond
  3.              ((atom tree)
  4.               (funcall function tree))
  5.              ((consp tree)
  6.               (cons (mapatoms function (car tree))
  7.                     (mapatoms function (cdr tree)))))))
  8.   (mapatoms (lambda (atom)
  9.               (format t "~A~%" atom)
  10.               (read-from-string (format nil "~S" atom)))
  11.             '(defmacro (x) `(list ,x))))
  12.  
  13. ;; output:
  14. ;; DEFMACRO
  15. ;; X
  16. ;; NIL
  17. ;; QUASIQUOTE
  18. ;; LIST
  19. ;; ,X
  20. ;;
  21. ;; Comma not inside a backquote.
  22. ;;
  23. ;;   Stream: #<dynamic-extent STRING-INPUT-STREAM (unavailable) from ",X">
  24. ;;    [Condition of type SB-INT:SIMPLE-READER-ERROR]
  25. ;;
  26. ;; Restarts:
  27. ;;  0: [RETRY] Retry SLIME REPL evaluation request.
  28. ;;  1: [*ABORT] Return to SLIME's top level.
  29. ;;  2: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1002B59D33}>)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement