diff --git a/d-.scm b/d-.scm index 7f73a01..a01fb1a 100644 --- a/d-.scm +++ b/d-.scm @@ -48,9 +48,9 @@ (define (partial fn . args) (lambda x (apply fn (append args x)))) -(define (argmin f . vals) +(define (argmin arg lt? . vals) (reduce (lambda (val min) - (if (< (f val) (f min)) + (if (lt? (arg val) (arg min)) val min)) #f diff --git a/test.scm b/test.scm index d596ab0..a163432 100644 --- a/test.scm +++ b/test.scm @@ -53,4 +53,4 @@ (define-test argmin (test - (assert (equal? (argmin cdr '(a . 5) '(b . 2) '(c . 3)) '(b . 2))))) + (assert (equal? (argmin cdr < '(a . 5) '(b . 2) '(c . 3)) '(b . 2)))))