Changeset 33549 in project
 Timestamp:
 07/31/16 01:01:50 (5 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

wiki/eggref/4/srfi128
r33545 r33549 60 60 standard Scheme types: 61 61 62 <e mscript highlight="scheme">62 <enscript highlight="scheme"> 63 63 (makecomparator boolean? boolean=? (lambda (x y) (and (not x) y)) booleanhash) 64 </e mscript>64 </enscript> 65 65 66 66 will return a comparator for booleans, expressing the ordering {{#f}} < {{#t}} and the 67 67 standard hash function for booleans. 68 68 69 <e mscript highlight="scheme">69 <enscript highlight="scheme"> 70 70 (makecomparator real? = < (lambda (x) (exact (abs x)))) 71 </e mscript>71 </enscript> 72 72 73 73 will return a comparator expressing the natural ordering of real numbers and a 74 74 plausible (but not optimal) hash function. 75 75 76 <e mscript highlight="scheme">76 <enscript highlight="scheme"> 77 77 (makecomparator string? string=? string<? stringhash) 78 </e mscript>78 </enscript> 79 79 80 80 will return a comparator expressing the implementation's ordering of strings 81 81 and the standard hash function. 82 82 83 <e mscript highlight="scheme">83 <enscript highlight="scheme"> 84 84 (makecomparator string? stringci=? stringci<? stringcihash) 85 </e mscript>85 </enscript> 86 86 87 87 will return a comparator expressing the implementation's caseinsensitive … … 103 103 * The type test returns {{#t}} if its argument satisfies {{typetest}} and the elements satisfy the type test predicate of elementcomparator. 104 104 * The total order defined by the equality and ordering functions is as follows (known as lexicographic order): 105 106 107 105 ** The empty sequence, as determined by calling {{empty?}}, compares equal to itself. 106 ** The empty sequence compares less than any nonempty sequence. 107 ** Two nonempty sequences are compared by calling the {{head}} procedure on each. If the heads are not equal when compared using {{elementcomparator}}, the result is the result of that comparison. Otherwise, the results of calling the {{tail}} procedure are compared recursively. 108 108 * The {{hash}} function computes the hash values of the elements using the hash function of {{elementcomparator}} and then hashes them together in an implementationdefined way. 109 109 … … 119 119 Here is an example, which returns a comparator for byte vectors: 120 120 121 <e mscript highlight="scheme">121 <enscript highlight="scheme"> 122 122 (makevectorcomparator 123 123 (makecomparator exactinteger? = < numberhash) … … 125 125 bytevectorlength 126 126 bytevectoru8ref) 127 </e mscript>127 </enscript> 128 128 129 129 <procedure>(makeeqcomparator)</procedure> … … 207 207 208 208 * Given disjoint types {{a}} and {{b}}, one of three conditions must hold: 209 210 211 209 ** All objects of type {{a}} compare less than all objects of type {{b}}. 210 ** All objects of type {{a}} compare greater than all objects of type {{b}}. 211 ** All objects of both type {{a}} and type {{b}} compare equal to each other. This is not permitted for any of the Scheme types mentioned below. 212 212 * The empty list must be ordered before all pairs. 213 213 * When comparing booleans, it must use the total order {{#f}} < {{#t}}.
Note: See TracChangeset
for help on using the changeset viewer.