aboutsummaryrefslogtreecommitdiff
path: root/algebraic-structures.monoid.fold.scm
diff options
context:
space:
mode:
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)))