diff options
-rw-r--r-- | share/txr/stdlib/build.tl | 10 | ||||
-rw-r--r-- | txr.1 | 7 |
2 files changed, 11 insertions, 6 deletions
diff --git a/share/txr/stdlib/build.tl b/share/txr/stdlib/build.tl index c5fc5866..1ee166af 100644 --- a/share/txr/stdlib/build.tl +++ b/share/txr/stdlib/build.tl @@ -67,13 +67,13 @@ (:method get (self) (cdr self.head))) -(defun sys:list-builder-macrolets (lb-form) +(defun sys:list-builder-flets (lb-form) (nconc (collect-each ((op '(add add* pend pend* ncon ncon*))) - ^(,op (. forms) - ^(qref ,',lb-form (,',op ,*forms)))) + ^(,op (. args) + (qref ,lb-form (,op . args)))) ^((get () - ^(qref ,',lb-form (get)))))) + (qref ,lb-form (get)))))) (defun build-list (: init) (new list-builder head init)) @@ -81,6 +81,6 @@ (defmacro build (. forms) (with-gensyms (name) ^(let ((,name (new list-builder))) - (macrolet ,(sys:list-builder-macrolets name) + (flet ,(sys:list-builder-flets name) ,*forms (qref ,name (get)))))) @@ -27203,7 +27203,7 @@ Instead, creates a lexical environment in which a .code list-builder object is implicitly constructed and bound to a hidden variable. -Local macros which mimic the +Local functions which mimic the .code list-builder methods operate implicitly on this hidden variable, so that the object need not be mentioned as an argument. @@ -27225,6 +27225,11 @@ the object need not be mentioned as an argument. (add 1 2) (pend (get)) (pend (get))) -> (1 2 1 2 1 2 1 2) + + ;; build a list by mapping over the local + ;; add function: + + (build [mapdo add (range 1 3)]) -> (1 2 3) .cble .SS* Permutations and Combinations |