Skip to content

Instantly share code, notes, and snippets.

@PuercoPop
Created April 11, 2014 02:39
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 PuercoPop/10438073 to your computer and use it in GitHub Desktop.
Save PuercoPop/10438073 to your computer and use it in GitHub Desktop.
#+BEGIN_SRC lisp :results
(defun square (x)
(* x x))
(macro-expand '(loop
:for num :from 3 upto 6
:collect (square num)))
#+END_SRC
What I get
#+RESULTS:
| BLOCK | NIL | (LET ((NUM 3)) (DECLARE (TYPE (AND REAL NUMBER) NUM)) (SB-LOOP::WITH-LOOP-LIST-COLLECTION-HEAD (LOOP-LIST-HEAD-1257 LOOP-LIST-TAIL-1258) (SB-LOOP::LOOP-BODY NIL (NIL NIL (WHEN (> NUM (quote 6)) (GO SB-LOOP::END-LOOP)) NIL) ((SB-LOOP::LOOP-COLLECT-RPLACD (LOOP-LIST-HEAD-1257 LOOP-LIST-TAIL-1258) (LIST (SQUARE NUM)))) (NIL (SB-LOOP::LOOP-REALLY-DESETQ NUM (1+ NUM)) (WHEN (> NUM (quote 6)) (GO SB-LOOP::END-LOOP)) NIL) ((RETURN-FROM NIL (SB-LOOP::LOOP-COLLECT-ANSWER LOOP-LIST-HEAD-1257)))))) |
What I want
#+RESULTS:
#+BEGIN_SRC lisp
(BLOCK NIL
(LET ((NUM 3))
(DECLARE (TYPE (AND REAL NUMBER) NUM))
(LET* ((#:LOOP-LIST-HEAD-1251 (LIST NIL))
(#:LOOP-LIST-TAIL-1252 #:LOOP-LIST-HEAD-1251))
(TAGBODY
SB-LOOP::NEXT-LOOP
(IF (> NUM '6)
(PROGN (GO SB-LOOP::END-LOOP))
NIL)
(RPLACD #:LOOP-LIST-TAIL-1252
(SETQ #:LOOP-LIST-TAIL-1252 (LIST (SQUARE NUM))))
(SETQ NUM (1+ NUM))
(GO SB-LOOP::NEXT-LOOP)
SB-LOOP::END-LOOP
(RETURN-FROM NIL (CDR #:LOOP-LIST-HEAD-1251))))))
#+END_SRC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment