Guest User

Untitled

a guest
Jun 19th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. (defmacro accum-uniq (f &body body)
  2. (let ((f (if (consp f) f (list f))))
  3. `(let (#1=#:acc)
  4. (flet ((,(car f) (#2=#:val) (pushnew #2# #1# ,@(cdr f))))
  5. ,@body)
  6. #1#)))
  7.  
  8. (accum-uniq (a :test #'string=)
  9. (dotimes (i 100)
  10. (a (write-to-string (random 10)))))
  11. ;-> ("8" "0" "6" "2" "4" "5" "9" "7" "3" "1")
Add Comment
Please, Sign In to add comment