[gimp] R5RS compatibility fix for min and max (take 2) (SourceForge bug #3399331) It works better if I also
- From: Kevin Cozens <kcozens src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] R5RS compatibility fix for min and max (take 2) (SourceForge bug #3399331) It works better if I also
- Date: Mon, 29 Aug 2011 21:27:34 +0000 (UTC)
commit 6af99d4793c7908a171ff047006fc65d79128691
Author: Kevin Cozens <kcozens svn gnome org>
Date: Mon Aug 29 17:10:58 2011 -0400
R5RS compatibility fix for min and max (take 2) (SourceForge bug #3399331)
It works better if I also update the script-fu.init file used by Script-Fu.
plug-ins/script-fu/scripts/script-fu.init | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/plug-ins/script-fu/scripts/script-fu.init b/plug-ins/script-fu/scripts/script-fu.init
index f0d5d14..219bddf 100644
--- a/plug-ins/script-fu/scripts/script-fu.init
+++ b/plug-ins/script-fu/scripts/script-fu.init
@@ -70,10 +70,21 @@
(define (abs n) (if (>= n 0) n (- n)))
(define (exact->inexact n) (* n 1.0))
(define (<> n1 n2) (not (= n1 n2)))
+
+; min and max must return inexact if any arg is inexact; use (+ n 0.0)
(define (max . lst)
- (foldr (lambda (a b) (if (> a b) a b)) (car lst) (cdr lst)))
+ (foldr (lambda (a b)
+ (if (> a b)
+ (if (exact? b) a (+ a 0.0))
+ (if (exact? a) b (+ b 0.0))))
+ (car lst) (cdr lst)))
(define (min . lst)
- (foldr (lambda (a b) (if (< a b) a b)) (car lst) (cdr lst)))
+ (foldr (lambda (a b)
+ (if (< a b)
+ (if (exact? b) a (+ a 0.0))
+ (if (exact? a) b (+ b 0.0))))
+ (car lst) (cdr lst)))
+
(define (succ x) (+ x 1))
(define (pred x) (- x 1))
(define gcd
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]