Polishing the README and iterator protocol.

* README.md: added some small documentation and loop expansion.
 * goof.scm: Changed the iterator protocol to not use unnecessary :acc and :fors.
 * iterators.scm: see above.
 * ref-let.scm: a new macro to allow multiple values and pattern matching to co-exist for body-bindings.
This commit is contained in:
Linus 2020-12-16 19:54:55 +01:00
parent aab9fcabb0
commit 2d35c9d6cf
4 changed files with 220 additions and 19 deletions

View file

@ -255,7 +255,7 @@
((accumulating :acc (kons final init) ((var cursor) ((initial i) . x)) n . rest)
(accumulating :acc (kons final i) ((var cursor) x) n . rest))
((accumulating :acc (kons final init) ((var cursor) (expr (if check))) n . rest)
(n :acc ((tmp-kons kons))
(n ((tmp-kons kons))
((cursor init (if check (tmp-kons expr cursor) cursor)))
()
()
@ -263,7 +263,7 @@
((var (final cursor)))
. rest))
((accumulating :acc (kons final init) ((var cursor) (expr)) n . rest)
(n :acc ((tmp-kons kons))
(n ((tmp-kons kons))
((cursor init (tmp-kons expr cursor)))
()
()
@ -273,16 +273,16 @@
(define-syntax folding
(syntax-rules (if :acc)
((_ :acc ((var) (init update (if guard))) n . rest)
((_ :acc ((var) (init update (if guard))) n . rest)
(n ()
((var init (if guard update var)))
() () ()
((var var))
. rest))
((_ :acc ((var) (init update)) n . rest)
(folding ((var) (init update (if #t))) n . rest))
(folding :acc ((var) (init update (if #t))) n . rest))
((_ :acc ((var) (init)) n . rest)
(folding ((var) (init var (if #t))) n . rest))))
(folding :acc ((var) (init var (if #t))) n . rest))))
(define-syntax listing
(syntax-rules (:acc)