Skip to content

Instantly share code, notes, and snippets.

@eshamster
Created January 23, 2016 03:20
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 eshamster/f52f2835db57bc38e022 to your computer and use it in GitHub Desktop.
Save eshamster/f52f2835db57bc38e022 to your computer and use it in GitHub Desktop.
(defun replace-dot-in-tree (tree)
(labels ((rec (rest)
(cond
((consp rest) (let (result)
(dolist-with-left (elem left rest)
(push (rec elem) result))
(nreverse result)))
(rest (replace-dot-sep rest)))))
(rec tree)))
"Example:
CL-USER> (defparameter x '(1 2 3 4 5))
X
CL-USER> (ps-experiment.base::dolist-with-left (var left x)
(print var)
(print left))
1
NIL
2
(1 2 3 4 5)
3
(2 3 4 5)
4
(3 4 5)
5
(4 5)
NIL
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment