aboutsummaryrefslogtreecommitdiff
path: root/algebraic-structures.monoid.fold.scm
diff options
context:
space:
mode:
authorMasaya Tojo <masaya@tojo.tokyo>2024-06-14 02:25:10 +0900
committerMasaya Tojo <masaya@tojo.tokyo>2024-06-14 02:25:10 +0900
commit326a2a122e76dd9252558551d3f5e61c4014c2c1 (patch)
treee15c4afe27f696fec5a548b6f230b38111bebf5c /algebraic-structures.monoid.fold.scm
parent9fc5da3b546ec101357fb826d7282a73cd790e83 (diff)
Fix foldable interfaces
Diffstat (limited to 'algebraic-structures.monoid.fold.scm')
-rw-r--r--algebraic-structures.monoid.fold.scm12
1 files changed, 9 insertions, 3 deletions
diff --git a/algebraic-structures.monoid.fold.scm b/algebraic-structures.monoid.fold.scm
index b18c03c..5e176f2 100644
--- a/algebraic-structures.monoid.fold.scm
+++ b/algebraic-structures.monoid.fold.scm
@@ -1,4 +1,10 @@
-(functor ((algebraic-structures monoid fold) (M (<> unit)) (F (foldl foldr))) (fold)
- (import scheme M F)
+(functor ((algebraic-structures monoid fold) (M (<> unit)) (F (fold))) (fold)
+ (import scheme M (rename F (fold foldable:fold)))
- (define (fold x) (foldl <> unit x)))
+ (define (fold x) (foldable:fold <> unit x))
+
+ (define (fold-map f x)
+ (foldable:fold (lambda (x acc)
+ (<> (f x) acc))
+ unit
+ x)))