diff options
author | colin <colin@cicadas.surf> | 2023-02-28 20:51:02 -0800 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2023-02-28 20:51:02 -0800 |
commit | 3d90c2896114dad5b0d8e3aa8dccfbdb1b712fd1 (patch) | |
tree | c50788be9bae2e97df7a9728f96a7ca6dd94ef7b | |
parent | 501dfc88435354a8fbb12cd8aaccddf9615dc5ff (diff) |
riff nickname; updated readme
-rw-r--r-- | README.org | 78 | ||||
-rw-r--r-- | package.lisp | 1 |
2 files changed, 79 insertions, 0 deletions
@@ -129,3 +129,81 @@ This is easer to understand through example: Outputs : ((1 2 3 4 5 6 7 8 9) (1 2 3 3 5 6 7 8 9)) + +** Other tools + +*** rev + +#+begin_src lisp :results verbatim + +(funcall (riff:rev #'cons) 1 2) + + +#+end_src + +#+RESULTS: +: (2 . 1) + +*** closure + +#+begin_src lisp :results verbatim + +(let ((x 0)) + (let ((inc + (riff:closure + (incf x)))) + (funcall inc :these :will :all :be :ignored) + (funcall inc))) + + +#+end_src + +#+RESULTS: +: 2 + +*** mapped + +#+begin_src lisp :results verbatim + +(funcall (riff:mapped #$(+ 10 $x) #$(format nil "--~a--" $x)) + 100) + + +#+end_src + +#+RESULTS: +: (110 "--100--") + +*** lambda-if + +#+begin_src lisp :results verbatim + +(let ((decide + (riff:lambda-if #'evenp + #$(format nil "It's even: ~a~%" $x) + #$(format nil "It's odd: ~a~%" $x)))) + (funcall decide 10)) + + +#+end_src + +#+RESULTS: +: It's even: 10 + +*** lambda-cond + +#+begin_src lisp :results verbatim +(let ((decider + (riff:lambda-cond + #$(< (length $x) 10) (constantly "It's short.") + #$(<= 10 (length $x) 20) #$(format nil "Medium length: ~a" (length $x)) + (constantly t) (constantly "Longish")))) + + (mapcar decider (list "short" "this is a bit longer" "and this one is too long probably"))) + +#+end_src + +#+RESULTS: +: ("It's short." "Medium length: 20" "Longish") + + diff --git a/package.lisp b/package.lisp index 280a253..545f61e 100644 --- a/package.lisp +++ b/package.lisp @@ -2,6 +2,7 @@ (defpackage #:lambda-riffs (:use #:cl) + (:nicknames #:riff) (:export #:closure #:mapped #:rev |