make-vector(3scm)

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

πŸ’– make-vector β€” allocate a new vector πŸ’–

okay so bestie, welcome to make-vector(3scm), coming at you straight out of the Scheme Programmer's Manual ✨ this is literally the page where you learn to birth a fresh lil vector, no cap.


🌸 LIBRARY 🌸

import it from whichever flavour of scheme you're living in today, they all got you:

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

πŸ¦‹ SYNOPSIS πŸ¦‹

(make-vector k)
(make-vector k fill)

πŸ’… DESCRIPTION πŸ’…

So like, make-vector hands you back a newly allocated vector with k elements in it. that's the whole vibe. πŸŽ€

if you pass that second argument, fill, then every single element gets initialized to fill β€” icon level behaviour honestly.

if you don't pass a second argument? then the initial contents of each element is unspecified. not "empty", not "zero", unspecified. so don't go assuming things, ok? πŸ™ˆ

πŸ‘‘ IMPLEMENTATION NOTES πŸ‘‘

ngl this is where it gets a lil real. implementations vary in how well they handle a large k argument β€” like, some slay, some do not.

vectors typically need approximately four or eight bytes per element, and a large k means the system can run out of memory. 😭 and if that happens? some implementations will crash while others raise &implementation-restriction. so yeah, big k is giving risk.

⭐ RETURN VALUES ⭐

exactly one value: a freshly allocated vector. that's it, that's the tea. 🫢

🌈 EXAMPLES 🌈

(make-vector 3 #f)  =>  #(#f #f #f)

ate, no crumbs. πŸ’€

🧚 COMPATIBILITY 🧚

this procedure works the same everywhere apart from error handling. same energy, different error drama. πŸ¦‹

πŸ’œ 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. you broke a rule, bestie.
  • 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, catastrophically. that's the actual word. πŸ’€)

πŸ”₯ SEE ALSO πŸ”₯

πŸ“ STANDARDS πŸ“

R4RS, IEEE Scheme, R5RS, R6RS, R7RS β€” she's certified everywhere, periodt. ✨

πŸŽ€ HISTORY πŸŽ€

This procedure first appeared in R2RS. an OG fr fr. πŸ‘‘

πŸ’– 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/. 🫢


ok that's the whole page, go forth and allocate responsibly πŸ’…

mwah πŸ’‹ β€” this was make-vector(3scm), dated 2023-07-22, from the scheme-manpages crew. catch you in the next manpage bestie! 🌸✨

πŸ“¦ where this page comes from