diff options
-rw-r--r-- | README.md | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -132,7 +132,24 @@ example apears at the end of the document, following the tutorial. (1 2 4) (1 2 3) (1 2 3 4)) -```` +``` + +Note: The above is just for demonstration purposes and is much slower +than a version you'd write without generators. Something like: + +``` lisp + +(defun powerset (xs) + (if (null xs) (list nil) + (let ((subsets (powerset (cdr xs)))) + (append subsets + (mapcar (lambda (subset) (cons (car xs) subset)) + subsets))))) +``` + +The "vanilla CL" version is MUCH faster, but may not be possible if +you're generating powersets of very long lists. The trade off, as +usual, is between speed and memory. ### A Kind Of Grep |