Skip to content

Commit 5c840e0

Browse files
committed
Fix min/fn, max/fn
1 parent 932d3d0 commit 5c840e0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/core/order.egi

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
(if (gt? x y) x y)))
3737

3838
(define $min/fn
39-
(lambda [$compare $x $y]
40-
(if (eq? (compare x y) <Less>) x y)))
39+
(lambda [$f $xs]
40+
(foldl 2#(if (eq? (f %1 %2) <Less>) %1 %2) (car xs) (cdr xs))))
4141

4242
(define $max/fn
43-
(lambda [$compare $x $y]
44-
(if (eq? (compare x y) <Greater>) x y)))
43+
(lambda [$f $xs]
44+
(foldl 2#(if (eq? (f %1 %2) <Greater>) %1 %2) (car xs) (cdr xs))))
4545

4646
(define $min (cambda $xs (foldl b.min (car xs) (cdr xs))))
4747
(define $max (cambda $xs (foldl b.max (car xs) (cdr xs))))

0 commit comments

Comments
 (0)