diff options
-rw-r--r-- | README.org | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -23,6 +23,12 @@ Here is a basic example #+begin_src lisp :results verbatim + (let ((xs (list 1 2 3 4 5 6))) + (remove-if-not (lambda (x) (member x xs)) + (loop repeat 20 collect (random 10)))) + + ;; could be written + (let ((xs (list 1 2 3 4 5 6))) (remove-if-not #$(member $x xs) (loop repeat 20 collect (random 10)))) @@ -46,7 +52,6 @@ as a parameter of the anonymous function being defined. Outputs : ((1 2) (10 10 10)) - *** Numbered Parameters Examples of numbered parameters: @@ -77,7 +82,7 @@ Outputs In the above ='second= is passed in as the first argument, and ='first= is passed as the second argument. -Interestingly the numbers do not have to be sequentail, they are +Interestingly the numbers do not have to be sequential, they are merely sorted in ascending order: #+begin_src lisp :results verbatim @@ -102,9 +107,17 @@ This is easer to understand through example: ;; map over a list of lists, subtracting 9 from any member of a list ;; that is greater than 9 -(mapcar #$(mapcar - #$$(if (> $$x 9) (- $$x 9) $$x) ; our nested form - $digit-list) +;; without lambda-riffs, you might do: + +(mapcar (lambda (digit-list) + (mapcar (lambda (x) (if (> x 9) (- x 9) x)) + digit-list)) + '((1 2 3 4 5 6 7 8 9) + (10 11 12 12 14 15 16 17 18))) + +;; with lambda-riffs, you can do + +(mapcar #$(mapcar #$$(if (> $$x 9) (- $$x 9) $$x) $digit-list) '((1 2 3 4 5 6 7 8 9) (10 11 12 12 14 15 16 17 18))) #+end_src |