Skip to content

Commit

Permalink
fix max and min implementation in stdlib
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwparas committed Dec 27, 2023
1 parent a3e9c46 commit dab1e7e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/steel-core/src/scheme/stdlib.scm
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,10 @@

(define fold (lambda (f a l) (foldl f a l)))
(define reduce (lambda (f a l) (fold f a l)))
(define max (lambda (x num-list) (fold (lambda (y z) (if (> y z) y z)) x (cons 0 num-list))))
(define min (lambda (x num-list) (fold (lambda (y z) (if (< y z) y z)) x (cons 536870911 num-list))))

(define max (lambda (x . num-list) (fold (lambda (y z) (if (> y z) y z)) x (cons 0 num-list))))
(define min
(lambda (x . num-list) (fold (lambda (y z) (if (< y z) y z)) x (cons 536870911 num-list))))

(define mem-helper
(lambda (pred op) (lambda (acc next) (if (and (not acc) (pred (op next))) next acc))))
Expand Down

0 comments on commit dab1e7e

Please sign in to comment.