diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-03-29 22:53:35 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-03-29 22:53:35 -0700 |
commit | 5f26f2f8baaf377e414660df4e71afce9c4f4f48 (patch) | |
tree | 738831f689670ed89a983b0fcb7d272241b10781 | |
parent | 8b8ca2e793f90aa58d7430b8f060c467cd41ec1b (diff) | |
download | txr-5f26f2f8baaf377e414660df4e71afce9c4f4f48.tar.gz txr-5f26f2f8baaf377e414660df4e71afce9c4f4f48.tar.bz2 txr-5f26f2f8baaf377e414660df4e71afce9c4f4f48.zip |
* lib.c (min2, max2): Semantics tweak. If the numbers are equal,
favor the left one.
* txr.1: Documented min and max.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | lib.c | 4 | ||||
-rw-r--r-- | txr.1 | 25 |
3 files changed, 34 insertions, 2 deletions
@@ -1,5 +1,12 @@ 2012-03-29 Kaz Kylheku <kaz@kylheku.com> + * lib.c (min2, max2): Semantics tweak. If the numbers are equal, + favor the left one. + + * txr.1: Documented min and max. + +2012-03-29 Kaz Kylheku <kaz@kylheku.com> + * arith.c (numeq): New function. (exptmod): Bugfix: was no normalizing the bignum, ouch. Also was reporting "non-integral operands" for other @@ -1285,12 +1285,12 @@ val numeqv(val first, val rest) val max2(val anum, val bnum) { - return if3(gt(anum, bnum), anum, bnum); + return if3(ge(anum, bnum), anum, bnum); } val min2(val anum, val bnum) { - return if3(lt(anum, bnum), anum, bnum); + return if3(le(anum, bnum), anum, bnum); } val maxv(val first, val rest) @@ -7087,6 +7087,31 @@ character will convert to integer. .SS Functions max and min +.TP +Syntax: + + (max <number> <number>*) + (min <number> <number>*) + +.TP +Description: + +The max and min functions determine and return the highest or lowest +value from among their arguments. + +The arguments must be numbers or characters. + +If only a single argument is given, that value is returned. + +If two arguments are given, then (max a b) is equivalent to (if (>= a b) a b), +and (min a b) is equivalent to (if (<= a b) a b). If the operands do not +have the same type, then one of them is converted to the type of the other; +however, the original unconverted values are returned. For instance +(max 4 3.0) yields the integer 4, not 4.0. + +If three or more arguments are given, max and min are left-associative. +Thus (max a b c) is (max (max a b) c). + .SS Functions search-regex and match-regex .SS Function regsub |