string=?(3scm)
π string=?(3scm) β the Scheme Programmer's Manual, but make it cute
okay so bestie, welcome to the 3scm corner of the Scheme Programmer's Manual, where we're talking about string=?, string<?, string>?, string<=?, and string>=? β yes, all five, they're a package deal π
β¨ NAME β¨
string=?, string<?, string>?, string<=?, string>=? β the string comparison girlies π
π LIBRARY π
like, pick your import era, they all work:
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
πΈ SYNOPSIS πΈ
(string=? string1 string2 string3 ...)
(string<? string1 string2 string3 ...)
(string>? string1 string2 string3 ...)
(string<=? string1 string2 string3 ...)
(string>=? string1 string2 string3 ...)
note that ... at the end babe β these take as many strings as you want, not just two π
π DESCRIPTION π
the equality one (string=?)
string=? hits you with #t if all the strings are the same length AND contain exactly the same characters in the same positions. otherwise? #f. no notes, it's giving exact match only π
the ordering ones
the ordering procedures return #t if their arguments are, respectively:
- monotonically increasing π
- monotonically decreasing π
- monotonically nondecreasing
- monotonically nonincreasing
and here's the tea β the behavior of the ordering procedures is different in R6RS and R7RS. main character conflict fr fr:
R6RS
these 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. and 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. so "z" < "zz", iconic behavior honestly β¨
R7RS
the ordering procedures compare strings in an implementation-defined way π they may work the same as in R6RS, or they could use some other ordering. it's giving "your mileage may vary" energy.
these predicates are required to be transitive though, that part is non-negotiable. in all cases, a pair of strings must satisfy exactly one of string<?, string=?, and string>?, and must satisfy string<=? if and only if they do not satisfy string>? and string>=? if and only if they do not satisfy string<?. like the friend group is consistent, no drama π
π RETURN VALUES π
these procedures return a single value; a boolean. that's it. #t or #f, pick one bestie π
π¦ EXAMPLES π¦
look at her go:
(string=? "StraΓe" "Strasse") => #f
(string<? "z" "Γ") => #t
(string<? "z" "zz") => #t
(string<? "z" "Z") => #f
yes the Γ is doing heavy lifting in these examples, we love a multilingual icon πΈ
β COMPATIBILITY β
the basic idea of these procedures is the same in all RnRS revisions. however, there are some differences. buckle up:
- R5RS and earlier reports only provided two-argument variants. two and only two, no plus-one π₯²
- R6RS implementations all work the same. consistency slay π
- R7RS implementations may lack support for some characters. the order is also implementation-defined, with lexicographical ordering only being one option. so don't come for me if your impl sorts weird, that's allowed π
π ERRORS π
this procedure can raise exceptions with the following condition types:
&assertion(R6RS) β the wrong number of arguments was passed or an argument was outside its domain.- R7RS β the assertions described above are errors. implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically. yes, catastrophically. that's the actual word. do not test it π
π₯ SEE ALSO π₯
char<?(3scm)string-ci=?(3scm)equal?(3scm)
go read those next, i'm obsessed with cross-referencing π«Ά
π§ STANDARDS π§
R4RS, IEEE Scheme, R5RS, R6RS, R7RS β she's certified in five standards, ate and left no crumbs π
π HISTORY π
these procedures first appeared in R2RS. fun lore: MacLisp had the samepnamep and alphalessp procedures that took two arguments and worked on both symbols and strings. vintage behavior, we respect the ancestors π
π AUTHORS π
this page is part of the scheme-manpages project. it includes materials from the RnRS documents. more information can be found at https://github.com/schemedoc/manpages/.
okay that's the whole page bestie, go compare some strings and slay π β¨
string=?(3scm) Β· Scheme Programmer's Manual Β· dated 2022-04-09 β mwah, catch you on the next manpage ππ¦π
π¦ where this page comes from
- nixpkgs unstable: scheme-manpages 0-unstable-2024-02-11
- π the page's license: MIT
- Copyright (c) 2022 Gwen Weinholt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms