diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-08-18 11:38:52 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-08-18 11:38:52 -0700 |
commit | 552b0a2ee81b48f74cec495c7323e3bcc2c43342 (patch) | |
tree | 7d12fc0d568c75252cc59ac9eca910889ce52872 | |
parent | 16e79be4fdd6bd3db26bf349f02e8e5b21367d2b (diff) | |
download | txr-552b0a2ee81b48f74cec495c7323e3bcc2c43342.tar.gz txr-552b0a2ee81b48f74cec495c7323e3bcc2c43342.tar.bz2 txr-552b0a2ee81b48f74cec495c7323e3bcc2c43342.zip |
doc: new buildn example.
* txr.1: Adding breadth-first traversal example showing queue
capability of the list-builder.
-rw-r--r-- | txr.1 | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -32462,6 +32462,21 @@ macro for deleting a place. ;; add function: (build [mapdo add (range 1 3)]) -> (1 2 3) + + ;; breadth-first traversal of nested list; + (defun bf-map (tree visit-fn) + (buildn + (add tree) + (whilet ((item (del))) + (if (atom item) + [visit-fn item] + (each ((el item)) + (add el)))))) + + (let (flat) + (bf-map '(1 (2 (3 4 (5))) ((6 7) 8)) (do push @1 flat)) + (nreverse flat)) + -> (1 2 8 3 4 6 7 5) .brev .SS* Permutations and Combinations |