string-fill!(3scm)
π string-fill!(3scm) β the Scheme Programmer's Manual, but make it cute
okay so bestie, welcome to string-fill!(3scm) β the little mutator that goes brrr on your strings β¨
πΈ NAME πΈ
string-fill! β fill a string with a character. that's it. that's the whole vibe π
π LIBRARY π
import it like this, depending on which flavour of Scheme you're living in:
(import (rnrs mutable-strings)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
β¨ SYNOPSIS β¨
(string-fill! string char)
(string-fill! string char start) ;R7RS
(string-fill! string char start end) ;R7RS
π DESCRIPTION π
So what it does: it stores char in every single element of string. every one. no survivors. it's giving total takeover π
R7RS β okay so here's the glow-up: it only modifies string between start (inclusive, she's invited) and end (exclusive, she's NOT). and if you omit them? start defaults to 0 and end defaults to the length of string. defaults serving, honestly π«Ά
π¦ RETURN VALUES π¦
- R6RS β returns unspecified values. plural. don't ask what they are, nobody knows π
- R7RS β returns an unspecified value. singular. still a mystery.
π EXAMPLES π
;; R7RS example
(let ((s (make-string 4 #\x)))
(string-fill! s #\y 2)
s) => "xxyy"
see how the first two stayed x and only the last two got the y treatment? that's the start argument doing her thing. icon behaviour β¨
π APPLICATION USAGE π
This procedure is for filling strings that already exist β like, they've been created, they're living their life, and now you're filling them. lowkey it has marginal utility ngl π because the second argument to make-string(3scm) fills the whole entire string right at creation time. so like... why not just do that? but hey, string-fill! is still here and she's still iconic π
π COMPATIBILITY π
The start and end arguments? Those are unique to R7RS. everyone else is not invited to that party π
π 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. basically you did it wrong and it noticed π
R7RS β the assertions described above are errors. and here's the messy part: implementations may signal an error, or extend the procedure's domain of definition to include such arguments, or fail catastrophically. yes, catastrophically. the drama is real ππ₯
π₯ SEE ALSO π₯
make-string(3scm)string-set!(3scm)
π STANDARDS π
R4RS, R5RS, R6RS, R7RS β she's been standard-issue for a minute π
πΈ HISTORY πΈ
The first Scheme report to carry this procedure was R2RS, and R2RS also had substring-fill! that filled a substring β but plot twist, it used a different argument order:
(substring-fill! string start end char)
anyway she's missing from IEEE Scheme. gone but not forgotten π―οΈ
π§ AUTHORS π§
This page is part of the scheme-manpages project. It includes materials from the RnRS documents. more info lives at https://github.com/schemedoc/manpages/.
fr fr bestie, that's the whole page. go fill some strings, and remember: start is inclusive, end is exclusive, and that's not a vibe, that's just the spec π
signed off with love, 2022-05-14 edition of string-fill!(3scm) β Scheme Programmer's Manual π«Ά
π¦ 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