Next: strings compar dictnumber, Previous: strings compar dict, Up: strings compar [Index]
String/numbers comparison splits the strings to compare into their numeric and non–numeric parts and compares the parts one by one; for example, the string ‘foo4bar3zab10’ is split into the following list:
("foo" 4 "bar" 3 "zab" 10)
in which non–numeric parts are retained as Scheme strings and numeric
parts become exact integers; numeric parts only become exact
integer, never flonums. String parts are compared with the ordinary
lexicographic operators string<?
and string=?
(or
string-ci<?
and string-ci=?
), while numeric parts are
compared with the ordinary <
and =
operators; a string
part and a numeric part are compared by converting the number into a
string, then using string<?
and string=?
.
Miscellaneous examples:
(string/numbers<? "123" "45") ⇒ #f (string/numbers<? "ciao3" "ciao10") ⇒ #t (string/numbers<? "foo4bar3zab10" "foo4bar3zab2") ⇒ #f (string/numbers<? "foo4bar10" "foo4bar3zab") ⇒ #f
Compare the string and numeric parts of the arguments and return a ternary result: ‘-1’ if str1 is less than str2, ‘0’ if str1 is equal to str2, ‘+1’ if str1 is greater than str2. The comparison is case sensitive.
Return #t
or #f
, whether the string arguments comply with the
predicate.
Compare the string and numeric parts of the arguments and return a ternary result: ‘-1’ if str1 is less than str2, ‘0’ if str1 is equal to str2, ‘+1’ if str1 is greater than str2. The comparison is case insensitive.
Return #t
or #f
, whether the string arguments comply with the
predicate. The comparison is case insensitive.
Next: strings compar dictnumber, Previous: strings compar dict, Up: strings compar [Index]