Guest User

Untitled

a guest
Jun 17th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. (setq my-data '((0 A) (1 B) (2 C)))
  2.  
  3. (loop for (x y) in my-data
  4. collect (list y x))
  5. ;=> ((A 0) (B 1) (C 2))
  6.  
  7. (mapcan (lambda (z)
  8. (destructuring-bind (x y) z
  9. (list (list y x))))
  10. my-data)
  11. ;=> ((A 0) (B 1) (C 2))
  12.  
  13. ;; (setq my-data '((0 A) (1 B) (2 C)))
  14. (let (res)
  15. (dolist (z my-data (nreverse res))
  16. (destructuring-bind (x y) z
  17. (push (list y x) res))))
  18. ;=> ((A 0) (B 1) (C 2))
Add Comment
Please, Sign In to add comment