Next: , Previous: SRFI-13 Modification, Up: SRFI-13


39.11.7 Comparison

The procedures in this section are used for comparing strings in different ways. The comparison predicates differ from those in R5RS in that they do not only return #t or #f, but the mismatch index in the case of a true return value.

string-hash and string-hash-ci are for calculating hash values for strings, useful for implementing fast lookup mechanisms.

— Scheme Procedure: string-compare s1 s2 proc_lt proc_eq proc_gt [start1 [end1 [start2 [end2]]]]
— Scheme Procedure: string-compare-ci s1 s2 proc_lt proc_eq proc_gt [start1 [end1 [start2 [end2]]]]

Apply proc_lt, proc_eq, proc_gt to the mismatch index, depending upon whether s1 is less than, equal to, or greater than s2. The mismatch index is the largest index i such that for every 0 <= j < i, s1[j] = s2[j] – that is, i is the first position that does not match.

— Scheme Procedure: string= s1 s2 [start1 end1 start2 end2]
— Scheme Procedure: string<> s1 s2 [start1 end1 start2 end2]
— Scheme Procedure: string< s1 s2 [start1 end1 start2 end2]
— Scheme Procedure: string> s1 s2 [start1 end1 start2 end2]
— Scheme Procedure: string<= s1 s2 [start1 end1 start2 end2]
— Scheme Procedure: string>= s1 s2 [start1 end1 start2 end2]

Compare s1 and s2 and return #f if the predicate fails. Otherwise, the mismatch index is returned (or end1 in the case of string=.

— Scheme Procedure: string-ci= s1 s2 [start1 end1 start2 end2]
— Scheme Procedure: string-ci<> s1 s2 [start1 end1 start2 end2]
— Scheme Procedure: string-ci< s1 s2 [start1 end1 start2 end2]
— Scheme Procedure: string-ci> s1 s2 [start1 end1 start2 end2]
— Scheme Procedure: string-ci<= s1 s2 [start1 end1 start2 end2]
— Scheme Procedure: string-ci>= s1 s2 [start1 end1 start2 end2]

Compare s1 and s2 and return #f if the predicate fails. Otherwise, the mismatch index is returned (or end1 in the case of string=. These are the case-insensitive variants.

— Scheme Procedure: string-hash s [bound [start [end]]]
— Scheme Procedure: string-hash-ci s [bound [start [end]]]

Return a hash value of the string s in the range 0 ... bound - 1. string-hash-ci is the case-insensitive variant. Optional third and fourth args start and end delimit the string.