diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-03-17 22:14:18 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-03-28 14:17:01 +0200 |
commit | 1da5a277188a954d881316cb605962ee66053285 (patch) | |
tree | 4f77be46498f321d08bfaa072636e4fd252b4f9d /module/hnh/util.scm | |
parent | Unsmarted define-config% (diff) | |
download | calp-1da5a277188a954d881316cb605962ee66053285.tar.gz calp-1da5a277188a954d881316cb605962ee66053285.tar.xz |
Normalize errors.
Diffstat (limited to 'module/hnh/util.scm')
-rw-r--r-- | module/hnh/util.scm | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/module/hnh/util.scm b/module/hnh/util.scm index 1b5ceeab..e766cd0a 100644 --- a/module/hnh/util.scm +++ b/module/hnh/util.scm @@ -247,18 +247,20 @@ ;; and the other items in some order. ;; Ord b => (list a) [, (b, b -> bool), (a -> b)] -> a, (list a) (define*-public (find-extreme items optional: (< <) (access identity)) - (if (null? items) - (error "Can't find extreme in an empty list") - (fold-values - (lambda (c min other) - (if (< (access c) (access min)) - ;; Current stream head is smaller that previous min - (values c (cons min other)) - ;; Previous min is still smallest - (values min (cons c other)))) - (cdr items) - ;; seeds: - (car items) '()))) + (when (null? items) + (scm-error 'wrong-type-arg "find-extreme" + "Can't find extreme in an empty list" + #f #f)) + (fold-values + (lambda (c min other) + (if (< (access c) (access min)) + ;; Current stream head is smaller that previous min + (values c (cons min other)) + ;; Previous min is still smallest + (values min (cons c other)))) + (cdr items) + ;; seeds: + (car items) '())) (define*-public (find-min list optional: (access identity)) (find-extreme list < access)) |