From 3d90c2896114dad5b0d8e3aa8dccfbdb1b712fd1 Mon Sep 17 00:00:00 2001 From: colin Date: Tue, 28 Feb 2023 20:51:02 -0800 Subject: riff nickname; updated readme --- README.org | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ package.lisp | 1 + 2 files changed, 79 insertions(+) diff --git a/README.org b/README.org index e3a9ef2..ac4f9f1 100644 --- a/README.org +++ b/README.org @@ -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 -- cgit v1.2.3