From 66cd2fda549d7708acb8685933e619b0922885d5 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Fri, 18 Nov 2022 20:05:29 +0100 Subject: add generator-xfold --- mew.scm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'mew.scm') 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) -- cgit 1.4.1