aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2021-03-14 12:28:01 -0500
committerColin Okay <okay@toyful.space>2021-03-14 12:28:01 -0500
commit7051b2606cc2935edad7f2d2c5b85e79c76e0a7c (patch)
tree2d2e8ff0985a8db0cf7e58292888761ac04afd81
parent225b28dee4a19d50e1e0c85a180b62eb73f170bc (diff)
speed v memory tradeoff note
-rw-r--r--README.md19
1 files changed, 18 insertions, 1 deletions
diff --git a/README.md b/README.md
index 3a6c383..a18d5b9 100644
--- a/README.md
+++ b/README.md
@@ -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