vector-fill!(3scm)

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

πŸ’… vector-fill! β€” fill a vector, bestie

okay so picture this: it's vector-fill! from the Scheme Programmer's Manual (that's 3scm for the section, iykyk) and she is literally here to fill your vector with one single object. every slot. no cap.


πŸ“š LIBRARY

so you gotta import her first, and she's chill about it β€” several vibes work:

(import (rnrs))                     ;R6RS
(import (rnrs base))                ;R6RS
(import (scheme r5rs))              ;R7RS
(import (scheme base))              ;R7RS

pick your era, queen. both houses accept her πŸ’–


✨ SYNOPSIS ✨

(vector-fill! vector obj)
(vector-fill! vector obj start)     ;R7RS
(vector-fill! vector obj start end) ;R7RS

look at those R7RS glow-ups. the extra args are a lewk.


πŸ¦‹ DESCRIPTION

so the whole plot is: she stores obj in every element of vector. like, all of them. every single one. periodt. πŸŽ€

R7RS β€” okay so the R7RS girlies get to be picky: the operation is limited to the elements between start (inclusive) and end (exclusive). those two default to 0 and the length of vector. so if you don't pass them, it's the full vector again, no worries bestie 🫢


🌸 RETURN VALUES

  • R6RS β€” returns unspecified values. plural. mysterious. she's not telling.
  • R7RS β€” returns an unspecified value. singular. equally mysterious. πŸ’€
ngl, don't build your whole program on whatever comes back here. she's giving nothing and that's the point.

πŸ“ EXAMPLES

here's the R7RS moment, as written:

;; This example is for R7RS
(define a (vector 1 2 3 4 5))
(vector-fill! a 'smash 2 4)
a         => #(1 2 smash smash 5)

the way smash just ate indices 2 and 3 and left 1 2 and 5 untouched?? iconic. πŸ”₯ (that's start inclusive, end exclusive, exactly like we said πŸ’…)


🧚 COMPATIBILITY

the R7RS variant of this procedure has extra arguments. that's it, that's the tea. ⭐


πŸ‘‘ ERRORS

she can raise exceptions with these condition types:

  • &assertion (R6RS) β€” the wrong number of arguments was passed, or an argument was outside its domain. πŸ™ˆ

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.

πŸ’€ fail catastrophically. she said it, not me. do not test her.

🌈 SEE ALSO


⭐ STANDARDS

R4RS, R5RS, R6RS, R7RS β€” she's been in the game across four standards, main character energy fr fr πŸ‘‘


πŸ’œ HISTORY

this procedure first appeared in R2RS. ancient. legendary. the blueprint. πŸŽ€


🫢 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/ ✨


kisses and unspecified values, bestie πŸ’– β€” page dated 2023-01-26, from the 3scm set, vector-fill!(3scm) forever and always 🌸

πŸ“¦ where this page comes from