string-hash(3scm)
π string-hash(3scm) β the Scheme Programmer's Manual, but make it cute
okay so bestie, this is a page from the Scheme Programmer's Manual and it's about two little string-hashing besties that feed your hashtables. let me tell you everything, no gatekeeping β¨
πΈ NAME πΈ
string-hash, string-ci-hash β the string hash functions, aka the girls who turn your strings into integers π
π LIBRARY π
(import (rnrs)) ;R6RS
(import (rnrs hashtables)) ;R6RS
both imports are literally right there, use whichever, iykyk π«Ά
β¨ SYNOPSIS β¨
(string-hash string)
(string-ci-hash string)
two procedures, one argument each, that's the whole vibe π
π DESCRIPTION π
So what these do: they return an integer hash value for string, based on its current contents. Like, whatever the string says right now, that's what gets hashed. Simple, iconic, no cap.
And the whole point? You use them with make-hashtable(3scm). That's the application, that's the moment, that's the main character energy π₯
π string-hash π
This one is suitable for use with string=?(3scm) as an equivalence function. they match, they're a set, periodt π
π¦ string-ci-hash π¦
This one ignores case β like it literally does not care whether you typed uppercase or lowercase, it's above all that. It's suitable for use with string-ci=?(3scm) as an equivalence function. see how the ci in both names lines up? that's not a coincidence bestie, that's chemistry π
β RETURN VALUES β
Returns a single value β an integer. one value, no drama, no multiple-values shenanigans π
π EXAMPLES π
(= (string-hash "Quux") (string-hash "Quux")) => #t
(= (string-ci-hash "quux") (string-hash "QUUX")) => #t
(= (string-hash "foo") (string-hash "bar")) => #t or #f
look at the first one β same string twice, same hash, #t, obviously, consistency queen π
second one β string-ci-hash of "quux" equals string-hash of "QUUX", #t?? wait no β read it carefully bestie, that's exactly what it says, copy it exactly, don't come for me π the point is case-sensitivity is doing its thing.
third one β "foo" and "bar" might collide or might not, #t or #f, that's just how hashing goes, it's giving chaos but it's fine π
π§ APPLICATION USAGE π§
This procedure is used as an argument to make-hashtable(3scm). like, you literally hand it over. that's its job. it's a team player π«Ά
π 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, don't do that. wrong arg count or a cursed argument and it WILL throw at you, and honestly? fair π
π SEE ALSO π
make-hashtable(3scm)β the one who actually calls these girls up π
π STANDARDS π
R6RS, SRFI-69. both. she's certified, she's documented, she's valid π
π HISTORY π
The first Scheme report to include this procedure was R6RS, for its new hashtable library. and there's a similar procedure in SRFI-69 β so like, the concept was around, R6RS just gave it the official glow-up β¨
π 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/. go check it out if you're nosy like me π΅οΈββοΈ
and that's the whole page bestie πΈ no cap, every flag and every fact intact, we ate and left no crumbs π
page dated 2022-05-12, from string-hash(3scm) β mwah, catch you in 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