aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2021-03-14 11:57:25 -0500
committerColin Okay <okay@toyful.space>2021-03-14 11:57:25 -0500
commit5e11ca9b467f7cd058864e6a21586edbaf22957e (patch)
tree0d54f957e06be51e5afb9b5ab3eb4d7b8542d5c3
parent8f39169531e25eb1513778a43ddfed465fc52a4c (diff)
added subset eg to readme
-rw-r--r--README.md29
1 files changed, 29 insertions, 0 deletions
diff --git a/README.md b/README.md
index 980c0c6..f68fc3f 100644
--- a/README.md
+++ b/README.md
@@ -104,6 +104,35 @@ example apears at the end of the document, following the tutorial.
```
+### Subsets
+
+``` lisp
+
+(defun all-subsets (list)
+ (if (null list) (seq (list nil))
+ (concat! (all-subsets (cdr list))
+ (map! (lambda (sub) (cons (car list) sub))
+ (all-subsets (cdr list))))))
+
+> (collect (all-subsets '()))
+(NIL)
+
+> (collect (all-subsets '(1)))
+(NIL (1))
+
+> (collect (all-subsets '(1 2)))
+(NIL (2) (1) (1 2))
+
+> (collect (all-subsets '(1 2 3)))
+(NIL (3) (2) (2 3) (1) (1 3) (1 2) (1 2 3))
+
+> (collect (all-subsets '(1 2 3 4)))
+(NIL (4) (3) (3 4) (2) (2 4) (2 3) (2 3 4) (1) (1 4) (1 3) (1 3 4) (1 2)
+ (1 2 4) (1 2 3) (1 2 3 4))
+
+
+````
+
### A Kind Of Grep
``` lisp