|Parameters||n, a number|
|Purpose||Determines if v is a rational number (expressible as a ratio of two integers).|
|Produces||A truth value: true (|
|Preconditions||Only one parameter (verified).|
|Postconditions||Returns true if and only if the parameter is a rational number. Note that my version of Scheme seems to treat any non-complex numbers as rational (hmmmm). Note also that values that are not numbers (e.g., lists and symbols) are not rational.|
> (rational? 1) #t > (rational? 3/2) #t > (rational? -1/2) #t > (rational? 1.3) #t > (rational? (sqrt 2)) #t > (exp 1) 2.718281828459045 > (rational? (exp 1)) #t > (rational? (sqrt -1)) #f > (rational? 'a) #f
Disclaimer: I usually create these pages on the fly. This means that they are rarely proofread and may contain bad grammar and incorrect details. It also means that I may update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.
This page was generated by Siteweaver on Thu Feb 22 05:48:16 2001.
This page may be found at
You may validate this page's HTML.
The source was last modified Wed Jan 31 22:41:19 2001.