char=?(3scm)

πŸ“¦ version 0-unstable-2024-02, in nixpkgs unstable

πŸ’… 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