Next: , Previous: , Up: srfi strings spec   [Index]


2.8.3.7 Comparison

Function: string-compare str1 str2 proc< proc= proc>
Function: string-compare str1 str2 proc< proc= proc> start1
Function: string-compare str1 str2 proc< proc= proc> start1 end1
Function: string-compare str1 str2 proc< proc= proc> start1 end1 start2
Function: string-compare str1 str2 proc< proc= proc> start1 end1 start2 end2

Apply proc<, proc=, or proc> to the mismatch index, depending upon whether str1 is less than, equal to, or greater than str2. 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 doesn’t match.

The optional start/end indices restrict the comparison to the indicated substrings of str1 and str2. The mismatch index is always an index into str1; in the case of proc=, it is always end1; we observe the protocol in this redundant case for uniformity.

(string-compare "The cat in the hat" "abcdefgh"
                values values values
                4 6         ; Select "ca"
                2 4)        ; & "cd"
=> 5    ; Index of S1's "a"

True text collation is not handled by this SRFI.

Function: string-compare-ci str1 str2 proc< proc= proc>
Function: string-compare-ci str1 str2 proc< proc= proc> start1
Function: string-compare-ci str1 str2 proc< proc= proc> start1 end1
Function: string-compare-ci str1 str2 proc< proc= proc> start1 end1 start2
Function: string-compare-ci str1 str2 proc< proc= proc> start1 end1 start2 end2

Case–insensitive variant of string-compare.

The following procedures are the lexicographic extensions to strings of the corresponding orderings on characters. For example, string< is the lexicographic ordering on strings induced by the ordering char<? on characters. If two strings differ in length but are the same up to the length of the shorter string, the shorter string is considered to be lexicographically less than the longer string.

The optional start/end indices restrict the comparison to the indicated substrings of str1 and str2.

True text collation is not handled by this SRFI.

Function: string= str1 str2
Function: string= str1 str2 start1
Function: string= str1 str2 start1 end1
Function: string= str1 str2 start1 end1 start2
Function: string= str1 str2 start1 end1 start2 end2

Lexicographic ordering on strings induced by the ordering char=? on characters.

Function: string<> str1 str2
Function: string<> str1 str2 start1
Function: string<> str1 str2 start1 end1
Function: string<> str1 str2 start1 end1 start2
Function: string<> str1 str2 start1 end1 start2 end2

Lexicographic ordering on strings induced by the negation of the ordering char=? on characters.

Function: string< str1 str2
Function: string< str1 str2 start1
Function: string< str1 str2 start1 end1
Function: string< str1 str2 start1 end1 start2
Function: string< str1 str2 start1 end1 start2 end2

Lexicographic ordering on strings induced by the ordering char<? on characters.

Function: string> str1 str2
Function: string> str1 str2 start1
Function: string> str1 str2 start1 end1
Function: string> str1 str2 start1 end1 start2
Function: string> str1 str2 start1 end1 start2 end2

Lexicographic ordering on strings induced by the ordering char>? on characters.

Function: string<= str1 str2
Function: string<= str1 str2 start1
Function: string<= str1 str2 start1 end1
Function: string<= str1 str2 start1 end1 start2
Function: string<= str1 str2 start1 end1 start2 end2

Lexicographic ordering on strings induced by the ordering char<=? on characters.

Function: string>= str1 str2
Function: string>= str1 str2 start1
Function: string>= str1 str2 start1 end1
Function: string>= str1 str2 start1 end1 start2
Function: string>= str1 str2 start1 end1 start2 end2

Lexicographic ordering on strings induced by the ordering char>=? on characters.

Function: string-ci= str1 str2
Function: string-ci= str1 str2 start1
Function: string-ci= str1 str2 start1 end1
Function: string-ci= str1 str2 start1 end1 start2
Function: string-ci= str1 str2 start1 end1 start2 end2

Case–insensitive variant of string=.

Function: string-ci<> str1 str2
Function: string-ci<> str1 str2 start1
Function: string-ci<> str1 str2 start1 end1
Function: string-ci<> str1 str2 start1 end1 start2
Function: string-ci<> str1 str2 start1 end1 start2 end2

Case–insensitive variant of string<>.

Function: string-ci< str1 str2
Function: string-ci< str1 str2 start1
Function: string-ci< str1 str2 start1 end1
Function: string-ci< str1 str2 start1 end1 start2
Function: string-ci< str1 str2 start1 end1 start2 end2

Case–insensitive variant of string<.

Function: string-ci> str1 str2
Function: string-ci> str1 str2 start1
Function: string-ci> str1 str2 start1 end1
Function: string-ci> str1 str2 start1 end1 start2
Function: string-ci> str1 str2 start1 end1 start2 end2

Case–insensitive variant of string>.

Function: string-ci<= str1 str2
Function: string-ci<= str1 str2 start1
Function: string-ci<= str1 str2 start1 end1
Function: string-ci<= str1 str2 start1 end1 start2
Function: string-ci<= str1 str2 start1 end1 start2 end2

Case–insensitive variant of string<=.

Function: string-ci>= str1 str2
Function: string-ci>= str1 str2 start1
Function: string-ci>= str1 str2 start1 end1
Function: string-ci>= str1 str2 start1 end1 start2
Function: string-ci>= str1 str2 start1 end1 start2 end2

Case–insensitive variant of string>=.

Function: string-hash str
Function: string-hash str bound
Function: string-hash str bound start
Function: string-hash str bound start end
Function: string-hash-ci str
Function: string-hash-ci str bound
Function: string-hash-ci str bound start
Function: string-hash-ci str bound start end

Compute a hash value for the string str and return it as a fixnum. bound is a non–negative exact integer specifying the range of the hash function. A positive value restricts the return value to the range between 0 included and bound excluded.

If bound is either zero or not given, it defaults to (greatest-fixnum).

The optional start/end indices restrict the hash operation to the indicated substring of str.

string-hash-ci is the case–insensitive variant.

Invariants:

(<= 0 (string-hash s b) (- b 1)) ; When B > 0.

(string=    s1 s2)
⇒ (= (string-hash s1 b)    (string-hash s2 b))

(string-ci= s1 s2)
⇒ (= (string-hash-ci s1 b) (string-hash-ci s2 b))

Next: , Previous: , Up: srfi strings spec   [Index]