aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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