Skip to content

Instantly share code, notes, and snippets.

@gadmyth
Last active December 21, 2015 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gadmyth/6277370 to your computer and use it in GitHub Desktop.
Save gadmyth/6277370 to your computer and use it in GitHub Desktop.
(defun pairs (x)
(labels ((pair-from-list (lst cum)
(let ((a (car lst)) (b (cadr lst)) (new-lst (cddr lst)))
(if (or (null a) (null b))
(reverse cum)
(progn
(pair-from-list new-lst (pushnew `(,a . ,b) cum)))))))
(pair-from-list x nil)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment