Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
streams and trees in elisp using loop
(let (stack
(stream '((START "a")
(START "b")
(START "c")
(TEXT "test 1")
(END "c")
(END "b")
(END "a"))))
(loop for (operator operand) in stream
do (case operator
(let ((element (list operand)))
(if stack
(setcdr (elt stack 0) (list element))
(push element stack))
(setq stack (list element))
(setq result stack))))
(setcdr (elt stack 0) (list operand)))
(pop stack)))) result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment