char=?(3scm)
π char=?(3scm) β ok so bestie, let's talk characters
Welcome to the Scheme Programmer's Manual entry for char=?(3scm), aka the character comparison girlies π no cap, these five procedures are about to be your new faves.
β¨ NAME β¨
char=?, char<?, char>?, char<=?, char>=? β character comparison, periodt π
π LIBRARY π
Pick your import, bestie β there's literally one for every era:
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
π¦ SYNOPSIS π¦
(char=? char char char ...)
(char<? char char char ...)
(char>? char char char ...)
(char<=? char char char ...)
(char>=? char char char ...)
Okay so the vibe check here: every single one takes char after char after char β¦ like a whole group chat of characters π±β¨
πΈ DESCRIPTION πΈ
So here's the tea β β these procedures return #t if the results of passing their arguments to char->integer are, respectively:
- equal β
char=? - monotonically increasing β
char<? - monotonically decreasing β
char>? - monotonically nondecreasing β
char<=? - monotonically nonincreasing β
char>=?
β¦and #f otherwise. Simple as that, iykyk π
And in R6RS systems, these procedures impose a total ordering on the set of characters according to their Unicode scalar values. Iconic behavior only π
β RETURN VALUES β
Returns a single boolean value. That's it, that's the whole return. #t or #f, no in-between, no situationships π
π₯ EXAMPLES π₯
(char<? #\z #\Γ) => #t
(char<? #\z #\Z) => #f
Not the lowercase z losing to Γ β the Unicode scalar value said what it said π«Ά
π COMPATIBILITY π
Okay so both R6RS and R7RS define the order based on the Unicode scalar values of characters, but heads up: R7RS does not require full Unicode support and also permits non-Unicode characters. So like, your mileage may vary depending on your implementation, ngl π
These procedures exist in R5RS and earlier reports too, but plot twist: they were only required to support two arguments. Two!! π So if you're going way back, keep that in mind.
And IEEE Scheme uses the β€ and β₯ characters instead of <= and >= in the procedure entries β but like, that's probably a typo. Not me defending them, that's literally what the docs say π
π 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. So like, count your args bestie, and don't be handing over anything that isn't a character β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.
fr fr "fail catastrophically" is right there in the spec. Like, that's not me being dramatic, that's the actual wording. Be careful out there π«£
π§ SEE ALSO π§
char-ci=?(3scm)β the case-insensitive bestie, go show her some love π
π STANDARDS π
R4RS, IEEE Scheme, R5RS, R6RS, R7RS β she's been around, she's got range, she's literally a legacy icon β
π 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/
And that's the whole page bestie π this cutie dropped on 2021-02-20 as part of char=?(3scm) from the Scheme Programmer's Manual β stay slay, stay sorted, and may all your characters be monotonically increasing πΈβ¨π¦
π¦ where this page comes from
- nixpkgs unstable: scheme-manpages 0-unstable-2024-02-11
- π the page's license: MIT
- Copyright (c) 2021 Gwen Weinholt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms