Created
March 29, 2015 12:16
-
-
Save MarkLavrynenko/103feabce9e63ad39d22 to your computer and use it in GitHub Desktop.
Revisions
-
MarkLavrynenko created this gist
Mar 29, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ ;Macro study (defun range-helper(x) (if (= x 0) (list x) (cons x (range-helper (- x 1))) ) ) (defun range (x) (reverse (range-helper (- x 1))) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;stupid way (defvar ans nil) (loop for x in (range 10) if (= 0 (mod x 2)) do (setq ans (append ans (list x))) ) (print ans) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wise way (defmacro lcomp (expression for var in list conditional condition-test) (let ((result (gensym))) `(let ((,result nil)) (loop for ,var in ,list ,conditional ,condition-test do (setq ,result (append ,result (list ,expression)))) ,result))) (setq ans2 (lcomp (+ (* x x) 10) for x in (range 10) if (= 0 (mod x 2)))) (print ans2)