vector-copy!(3scm)

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

✨ vector-copy! β€” copy elements between vectors ✨

okay so this is vector-copy!(3scm), straight out of the Scheme Programmer's Manual, and bestie it's literally just vibes and vector shuffling πŸ’…


πŸ“š LIBRARY

(import (scheme base))              ;R7RS

yep that's the one, (scheme base), R7RS girlies rise 🫢


🌸 SYNOPSIS

(vector-copy! to at from)
(vector-copy! to at from start)
(vector-copy! to at from start end)

three whole forms, choose your fighter ✨


πŸ’– DESCRIPTION

So what it does is: it copies the elements of the vector from between start and end β€” into the vector to, starting at the index at. that's it. that's the whole thing. slay πŸŽ€


🧚 IMPLEMENTATION NOTES

okay this part is the lore πŸ‘‘

The order in which elements are copied is unspecified β€” like, genuinely nobody promised you a direction, bestie β€” except that if the source and destination overlap, copying takes place as if the source is first copied into a temporary vector and then into the destination.

and here's the iconic bit: you can achieve that without allocating storage by making sure to copy in the correct direction in such circumstances. no extra memory, just big brain energy 🧠✨


πŸ¦‹ RETURN VALUES

Returns an unspecified value. don't @ me, it's not giving you anything back 😭


🌈 EXAMPLES

(define a (vector 1 2 3 4 5))
(define b (vector 10 20 30 40 50))
(vector-copy! b 1 a 0 2)
b                           => #(10 1 2 40 50)

look at that. #(10 1 2 40 50). the 10, the 1 2 snuggled in the middle, the 40 50 holding it down at the end. ate and left no crumbs πŸ”₯


⭐ COMPATIBILITY

This procedure is unique to R7RS πŸ‘‘ β€” main character, no remakes. but if you want compatible procedures, they can be found in SRFI-43 and SRFI-133. iykyk πŸ’œ


πŸ’€ ERRORS

⚠️ listen up, this is the part where things go sideways ⚠️

It is an error if:

  • the wrong number of arguments was passed, or
  • an argument was outside its domain.

It is an error if at is less than zero or greater than the length of to.

It is also an error if (- (vector-length to) at) is less than (- end start).

and then β€” the chaotic part β€” implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically. yes. catastrophically. πŸ™ˆ like genuinely could just explode. no cap.


πŸ” SEE ALSO


πŸŽ€ STANDARDS

R7RS ⭐


πŸ•°οΈ HISTORY

R7RS got this procedure from SRFI-43. so it's giving hand-me-down but make it iconic πŸ’…


πŸ‘‘ 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/. absolute legends, honestly 🌸


and that's the page bestie!! πŸ’– dated 2023-01-26, brought to you by the scheme-manpages crew β€” go drink some water and go copy some vectors responsibly πŸ“βœ¨

πŸ“¦ where this page comes from