diff options
author | Colin Okay <okay@toyful.space> | 2021-03-14 11:57:25 -0500 |
---|---|---|
committer | Colin Okay <okay@toyful.space> | 2021-03-14 11:57:25 -0500 |
commit | 5e11ca9b467f7cd058864e6a21586edbaf22957e (patch) | |
tree | 0d54f957e06be51e5afb9b5ab3eb4d7b8542d5c3 | |
parent | 8f39169531e25eb1513778a43ddfed465fc52a4c (diff) |
added subset eg to readme
-rw-r--r-- | README.md | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -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 |