Next: , Previous: String Modification, Up: Strings


5.5.5.7 String Comparison

The procedures in this section are similar to the character ordering predicates (see Characters), but are defined on character sequences.

The first set is specified in R5RS and has names that end in ?. The second set is specified in SRFI-13 and the names have no ending ?. The predicates ending in -ci ignore the character case when comparing strings.

— Scheme Procedure: string=? s1 s2

Lexicographic equality predicate; return #t if the two strings are the same length and contain the same characters in the same positions, otherwise return #f.

The procedure string-ci=? treats upper and lower case letters as though they were the same character, but string=? treats upper and lower case as distinct characters.

— Scheme Procedure: string<? s1 s2

Lexicographic ordering predicate; return #t if s1 is lexicographically less than s2.

— Scheme Procedure: string<=? s1 s2

Lexicographic ordering predicate; return #t if s1 is lexicographically less than or equal to s2.

— Scheme Procedure: string>? s1 s2

Lexicographic ordering predicate; return #t if s1 is lexicographically greater than s2.

— Scheme Procedure: string>=? s1 s2

Lexicographic ordering predicate; return #t if s1 is lexicographically greater than or equal to s2.

— Scheme Procedure: string-ci=? s1 s2

Case-insensitive string equality predicate; return #t if the two strings are the same length and their component characters match (ignoring case) at each position; otherwise return #f.

— Scheme Procedure: string-ci<? s1 s2

Case insensitive lexicographic ordering predicate; return #t if s1 is lexicographically less than s2 regardless of case.

— Scheme Procedure: string-ci<=? s1 s2

Case insensitive lexicographic ordering predicate; return #t if s1 is lexicographically less than or equal to s2 regardless of case.

— Scheme Procedure: string-ci>? s1 s2

Case insensitive lexicographic ordering predicate; return #t if s1 is lexicographically greater than s2 regardless of case.

— Scheme Procedure: string-ci>=? s1 s2

Case insensitive lexicographic ordering predicate; return #t if s1 is lexicographically greater than or equal to s2 regardless of case.

— Scheme Procedure: string-compare s1 s2 proc_lt proc_eq proc_gt [start1 [end1 [start2 [end2]]]]
— C Function: scm_string_compare (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-compare-ci s1 s2 proc_lt proc_eq proc_gt [start1 [end1 [start2 [end2]]]]
— C Function: scm_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. The character comparison is done case-insensitively.

— Scheme Procedure: string= s1 s2 [start1 [end1 [start2 [end2]]]]
— C Function: scm_string_eq (s1, s2, start1, end1, start2, end2)

Return #f if s1 and s2 are not equal, a true value otherwise.

— Scheme Procedure: string<> s1 s2 [start1 [end1 [start2 [end2]]]]
— C Function: scm_string_neq (s1, s2, start1, end1, start2, end2)

Return #f if s1 and s2 are equal, a true value otherwise.

— Scheme Procedure: string< s1 s2 [start1 [end1 [start2 [end2]]]]
— C Function: scm_string_lt (s1, s2, start1, end1, start2, end2)

Return #f if s1 is greater or equal to s2, a true value otherwise.

— Scheme Procedure: string> s1 s2 [start1 [end1 [start2 [end2]]]]
— C Function: scm_string_gt (s1, s2, start1, end1, start2, end2)

Return #f if s1 is less or equal to s2, a true value otherwise.

— Scheme Procedure: string<= s1 s2 [start1 [end1 [start2 [end2]]]]
— C Function: scm_string_le (s1, s2, start1, end1, start2, end2)

Return #f if s1 is greater to s2, a true value otherwise.

— Scheme Procedure: string>= s1 s2 [start1 [end1 [start2 [end2]]]]
— C Function: scm_string_ge (s1, s2, start1, end1, start2, end2)

Return #f if s1 is less to s2, a true value otherwise.

— Scheme Procedure: string-ci= s1 s2 [start1 [end1 [start2 [end2]]]]
— C Function: scm_string_ci_eq (s1, s2, start1, end1, start2, end2)

Return #f if s1 and s2 are not equal, a true value otherwise. The character comparison is done case-insensitively.

— Scheme Procedure: string-ci<> s1 s2 [start1 [end1 [start2 [end2]]]]
— C Function: scm_string_ci_neq (s1, s2, start1, end1, start2, end2)

Return #f if s1 and s2 are equal, a true value otherwise. The character comparison is done case-insensitively.

— Scheme Procedure: string-ci< s1 s2 [start1 [end1 [start2 [end2]]]]
— C Function: scm_string_ci_lt (s1, s2, start1, end1, start2, end2)

Return #f if s1 is greater or equal to s2, a true value otherwise. The character comparison is done case-insensitively.

— Scheme Procedure: string-ci> s1 s2 [start1 [end1 [start2 [end2]]]]
— C Function: scm_string_ci_gt (s1, s2, start1, end1, start2, end2)

Return #f if s1 is less or equal to s2, a true value otherwise. The character comparison is done case-insensitively.

— Scheme Procedure: string-ci<= s1 s2 [start1 [end1 [start2 [end2]]]]
— C Function: scm_string_ci_le (s1, s2, start1, end1, start2, end2)

Return #f if s1 is greater to s2, a true value otherwise. The character comparison is done case-insensitively.

— Scheme Procedure: string-ci>= s1 s2 [start1 [end1 [start2 [end2]]]]
— C Function: scm_string_ci_ge (s1, s2, start1, end1, start2, end2)

Return #f if s1 is less to s2, a true value otherwise. The character comparison is done case-insensitively.

— Scheme Procedure: string-hash s [bound [start [end]]]
— C Function: scm_substring_hash (s, bound, start, end)

Compute a hash value for S. the optional argument bound is a non-negative exact integer specifying the range of the hash function. A positive value restricts the return value to the range [0,bound).

— Scheme Procedure: string-hash-ci s [bound [start [end]]]
— C Function: scm_substring_hash_ci (s, bound, start, end)

Compute a hash value for S. the optional argument bound is a non-negative exact integer specifying the range of the hash function. A positive value restricts the return value to the range [0,bound).