string-length(3scm)
β¨ NAME β¨
string-length β bestie, it's literally just the length of a string π
π LIBRARY π
ok so you gotta import it from one of these, depending on your vibe:
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
π¦ SYNOPSIS π¦
(string-length string)
πΈ DESCRIPTION πΈ
It returns β as an exact integer object β the number of elements in string. That's it, that's the whole function, no cap π
Also the length of a string is fixed. Like, it does not change. Periodt.
π IMPLEMENTATION NOTES π
So all extant implementations use fixnums to represent string lengths, but ngl that's not required β it's just what everyone does. Not me calling them predictable, just saying π
β RETURN VALUES β
Returns a single value, and that value is the length of the string. One (1) value. Iconic behaviour, honestly π«Ά
π EXAMPLES π
(string-length "ABC")
=> 3
ate and left no crumbs π₯
π APPLICATION USAGE π
string-length is always popping up in code that decodes or encodes data in some protocol or file format, or that formats or parses strings. Like it's the main character of parsing code fr fr.
Sometimes the alternative is to use higher-order procedures β string-for-each(3scm), string-map(3scm) β or string ports: open-input-string(3scm), open-output-string(3scm). Options, bestie, we love options β¨
π§ COMPATIBILITY π§
Apart from error handling, this procedure is the same in all Scheme reports. Same energy across every report, we love consistency π
π 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β¦ you did too much π- 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 you read that right, catastrophic failure is on the menu, no notes π₯
π SEE ALSO π
make-string(3scm), string-ref(3scm), string-for-each(3scm), string-map(3scm), open-input-string(3scm).
go read them, iykyk π¦
π STANDARDS π
R4RS, IEEE Scheme, R5RS, R6RS, R7RS β she's certified in all five, obviously π
π 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/. shoutout to the whole squad π«Ά
π BUGS π
(empty, gorgeous, nothing to report β a flawless queen π)
ok that's the whole page bestie, mwah π β this was string-length(3scm) from the Scheme Programmer's Manual, dated 2021-01-03. see you in the group chat ππ¦β¨
π¦ 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