bytevector-copy(3scm)

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

πŸ’– NAME πŸ’–

bytevector-copy β€” bestie, it copies a bytevector, that's literally it

So this page lives in the Scheme Programmer's Manual (iconic company, no notes), and it's here to walk you through the one job this procedure has: duplicating bytes. Slay.


🌸 LIBRARY 🌸

ok so here's where you grab it from β€” pick your fave, they all work:

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

✨ SYNOPSIS ✨

(bytevector-copy bytevector)
(bytevector-copy bytevector start)      ;R7RS
(bytevector-copy bytevector start end)  ;R7RS

πŸ¦‹ DESCRIPTION πŸ¦‹

It hands you back a freshly allocated bytevector πŸŽ€ filled with the bytes from bytevector that live between start (inclusive, she's invited) and end (exclusive, she's not). Classic half-open interval behaviour, we love to see it.

And if you're feeling lazy (valid), the defaults got you:

  • start defaults to 0
  • end defaults to the length of the input

🫢 RETURN VALUES 🫢

You get a bytevector back, and its length is end - start. Math! But make it bytes. πŸ’…

πŸ”₯ EXAMPLES πŸ”₯

(define a #u8(1 2 3 4 5))
(bytevector-copy a 2 4))
   => #u8(3 4)

Look at her go. Grabbed index 2 and 3, dipped before 4. Main character energy fr fr.

😭 COMPATIBILITY 😭

Heads up bestie: the R6RS version of this procedure only has the first argument. So if you're passing start or end around in R6RS land, that's not gonna fly. 🫠

πŸ’€ ERRORS πŸ’€

Yes, it can raise exceptions with the following 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. 😭 Not "fail catastrophically" as a lil joke either β€” that's the actual wording. Stay safe out there.

πŸ‘‘ SEE ALSO πŸ‘‘

bytevector-copy!(3scm) β€” the destructive sibling, go say hi πŸ’œ

🌈 STANDARDS 🌈

R6RS, R7RS β€” certified, both of them, no cap ⭐

🧚 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/ β€” go check it out πŸ“


and that's the whole page, bestie!! brought to you by the scheme-manpages source, dated 2021-02-20, from bytevector-copy(3scm) β€” mwah πŸ’‹βœ¨πŸŽ€

πŸ“¦ where this page comes from