From 87384f611c05488791532250a1e3c49655220ca8 Mon Sep 17 00:00:00 2001 From: Dane Johnson Date: Mon, 11 Nov 2024 15:38:13 -0600 Subject: [PATCH] Must provide a predicate to argmin --- d-.scm | 4 ++-- test.scm | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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)))))