Next: , Previous: String Modification, Up: Strings


21.4.7 String Comparison

The procedures in this section are similar to the character ordering predicates (see Characters), but are defined on character sequences. They all return #t on success and #f on failure. The predicates ending in -ci ignore the character case when comparing strings.

— Scheme Procedure: string=? s1 s2
— C Function: scm_string_equal_p (s1, s2)

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

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
— C Function: scm_string_less_p (s1, s2)

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

— Scheme Procedure: string<=? s1 s2
— C Function: scm_string_leq_p (s1, s2)

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

— Scheme Procedure: string>? s1 s2
— C Function: scm_string_gr_p (s1, s2)

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

— Scheme Procedure: string>=? s1 s2
— C Function: scm_string_geq_p (s1, s2)

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

— Scheme Procedure: string-ci=? s1 s2
— C Function: scm_string_ci_equal_p (s1, s2)

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

— Scheme Procedure: string-ci<? s1 s2
— C Function: scm_string_ci_less_p (s1, s2)

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

— Scheme Procedure: string-ci<=? s1 s2
— C Function: scm_string_ci_leq_p (s1, s2)

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

— Scheme Procedure: string-ci>? s1 s2
— C Function: scm_string_ci_gr_p (s1, s2)

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

— Scheme Procedure: string-ci>=? s1 s2
— C Function: scm_string_ci_geq_p (s1, s2)

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