This page is part of the web mail archives of SRFI 73 from before July 7th, 2015. The new archives for SRFI 73 contain all messages, not just those from before July 7th, 2015.
| procedure: = z1 z2 z3 ... | procedure: < x1 x2 x3 ... | procedure: > x1 x2 x3 ... | procedure: <= x1 x2 x3 ... | procedure: >= x1 x2 x3 ... | These procedures return #t if their arguments are (respectively): | equal, monotonically increasing, monotonically decreasing, | monotonically nondecreasing, or monotonically nonincreasing. | | ... | (= 0 -0) ==> #t | | For any finite positive number x: | | (< #e-1/0 -x -0 0 x 1/0)) ==> #t | | These predicates are required to be transitive. A sequence cannot be both equal and monotonically increasing. (= -0 0) conflicts with (< -0 0). | library procedure: infinite? z "Infinite" means not finite. R5RS has `ZERO?' but not `NONZERO?'; `POSITIVE?', but not `NONPOSITIVE?'; `NEGATIVE?' but not `NONNEGATIVE?' `FINITE?' is more in keeping with R5RS procedure names. | library procedure: zero? z | library procedure: positive? x | library procedure: negative? x | library procedure: odd? n | library procedure: even? n | These numerical predicates test a number for a particular | property, returning #t or #f. See note above. | | (positive? #e1/0) ==> #t | (negative? #e-1/0) ==> #t | (infinite? #e-1/0) ==> #t | (infinite? #e0/0) ==> #t | (positive? 0) ==> #f | (negative? -0) ==> #f What does (zero? -0) return? If (negative? -0) returns #f, and (= -0 0) returns #t, how does one test for `-0'? | procedure: numerator q | procedure: denominator q | These procedures return the numerator or denominator of their | argument; the result is computed as if the argument was | represented as a fraction in lowest terms. The denominator is | always positive or zero. The denominator of 0 is defined to be | 1. | | (numerator (/ 6 4)) ==> 3 | (denominator (/ 6 4)) ==> 2 | (denominator | (exact->inexact (/ 6 4))) ==> 2.0 | *| (denominator #e1/0) ==> 1 *| (denominator #e-1/0) ==> -1 *| (numerator #e1/0) ==> 0 *| (numerator #e-1/0) ==> 0 *Should numerator and denominator be swapped in the last 4 lines? What does (exact? -0) return? What does (integer? -0) return? What does (rational? -0) return? What does (numerator -0) return? What does (denominator -0) return? What does (floor -0) return? What does (ceiling -0) return? What does (* -0 -0) return? What does (sqrt 0) return? | procedure: - z1 z2 | procedure: - z | optional procedure: - z1 z2 ... | procedure: / z1 z2 | procedure: / z | optional procedure: / z1 z2 ... | With one argument, these procedures return the additive or | multiplicative inverse of their argument. | | With two or more arguments: | | (- z1 . z2) => (apply + z1 (map - z2)) | (/ z1 . z2) => (apply * z1 (map / z2)) | | (- 0) ==> -0 | (- -0) ==> 0 | (- #e1/0) ==> #e-1/0 | (- #-e1/0) ==> #e1/0 | (- 3) ==> -3 | | (/ 0) ==> #e1/0 | (/ -0) ==> #e-1/0 *| (/ #e1/0) ==> #0 *| (/ #e-1/0) ==> #-0 | (/ 3) ==> 1/3 *Should `==> #' be replaced with `==> #e'? | Implementation | | Here is my implementation, which is based on a Scheme implementation | that supports arbitrary-big integer arithmetic as well as exact | rational number computation. To avoid confusion with identifies in | base-Scheme, all procedures defined in this SRFI (except infinite?) | and prefixed with "my" or "my-". This reference implementation also | requires SRFI-9, SRFI-13, SRFI-16, and SRFI-23. | | (separate file attached) There is no link to the implementation file.