vector-copy!(3scm)
β¨ 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
vector-copy(3scm)β the sibling, the prequel, the other one π«Ά
π 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
- nixpkgs unstable: scheme-manpages 0-unstable-2024-02-11
- π the page's license: MIT
- Copyright (c) 2023 Gwen Weinholt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms