diff options
author | Leah Neukirchen <leah@vuxu.org> | 2022-11-18 20:05:29 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2022-11-18 20:05:29 +0100 |
commit | 66cd2fda549d7708acb8685933e619b0922885d5 (patch) | |
tree | ab3f946810780b6174cb6b847ec684efbcc191dc /mew.scm | |
parent | b1605ef9a7f21e7caf3d033b5ac7df0b8da5c3fe (diff) | |
download | mew-66cd2fda549d7708acb8685933e619b0922885d5.tar.gz mew-66cd2fda549d7708acb8685933e619b0922885d5.tar.xz mew-66cd2fda549d7708acb8685933e619b0922885d5.zip |
add generator-xfold
Diffstat (limited to 'mew.scm')
-rw-r--r-- | mew.scm | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/mew.scm b/mew.scm index aa438bd..e4a07c0 100644 --- a/mew.scm +++ b/mew.scm @@ -6,8 +6,8 @@ dec def del-at div empty? eof esc fail fin final for fun* - gconcatenate gen generic-for-each genumerate get gfix giterate gmatch - gpick group-by-accumulator gslice-when gsplit gwindow + gconcatenate gen generator-xfold generic-for-each genumerate get + gfix giterate gmatch gpick group-by-accumulator gslice-when gsplit gwindow imp inc inject into juxt keys @@ -750,6 +750,14 @@ (hash-table-values items) (hash-table-update!/default items (f x) identity x))))))) + (define (generator-xfold f seed . gs) + (define (inner-xfold seed) + (let ((vs (map (lambda (g) (g)) gs))) + (if (any eof-object? vs) + seed + (inner-xfold (apply f seed vs))))) + (inner-xfold seed)) + (define-syntax one-of (er-macro-transformer (lambda (expr rename compare) |