Skip to content

Instantly share code, notes, and snippets.

@lgaff
Created April 30, 2012 03:47
Show Gist options
  • Save lgaff/2555273 to your computer and use it in GitHub Desktop.
Save lgaff/2555273 to your computer and use it in GitHub Desktop.
An argument for DSL's
;; The following two functions are equivalent:
(loop repeat 10 for x = 0 then y and y = 1 then (+ x y) collect y) ; ===> (1 1 2 3 5 8 13 21 34 55)
(BLOCK NIL
(LET ((#:LOOP-REPEAT-876 (CEILING 10)) (X NIL) (Y NIL))
(DECLARE (TYPE INTEGER #:LOOP-REPEAT-876))
(SB-LOOP::WITH-LOOP-LIST-COLLECTION-HEAD (#:LOOP-LIST-HEAD-877
#:LOOP-LIST-TAIL-878)
(SB-LOOP::LOOP-BODY NIL
((IF (<= #:LOOP-REPEAT-876 0)
(GO SB-LOOP::END-LOOP)
(DECF #:LOOP-REPEAT-876))
NIL
(SB-LOOP::LOOP-REALLY-DESETQ X
(PROG1 0
(SB-LOOP::LOOP-REALLY-DESETQ
Y 1)))
NIL NIL)
((SB-LOOP::LOOP-COLLECT-RPLACD
(#:LOOP-LIST-HEAD-877 #:LOOP-LIST-TAIL-878)
(LIST Y)))
((IF (<= #:LOOP-REPEAT-876 0)
(GO SB-LOOP::END-LOOP)
(DECF #:LOOP-REPEAT-876))
NIL
(SB-LOOP::LOOP-REALLY-DESETQ X
(PROG1 Y
(SB-LOOP::LOOP-REALLY-DESETQ
Y (+ X Y))))
NIL NIL)
((RETURN-FROM NIL
(SB-LOOP::LOOP-COLLECT-ANSWER
#:LOOP-LIST-HEAD-877))))))) ; ===> (1 1 2 3 5 8 13 21 34 55)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment