vector->string(3scm)

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

✨ vector->string(3scm) ✨

okay bestie, so this page is from the Scheme Programmer's Manual and we're about to make a vector of characters turn into a whole string. it's giving glow-up transformation, fr fr πŸ’…


🌸 NAME 🌸

vector->string β€” convert a vector of characters to a string

πŸŽ€ LIBRARY πŸŽ€

(import (scheme base))              ;R7RS

πŸ¦‹ SYNOPSIS πŸ¦‹

(vector->string vector)
(vector->string vector start)
(vector->string vector start end)

three ways to call it, pick your fighter πŸ‘‘

πŸ’– DESCRIPTION πŸ’–

Returns a newly allocated string of the objects contained in the elements of vector between start (inclusive) and end (exclusive). The order of the characters is preserved β€” no shuffling, no chaos, the vibes stay exactly where you put them ✨

The argument start defaults to 0 and end defaults to the length of vector. so if you're lazy (same) you can just pass the vector and let it do its thing 🫢

🧚 IMPLEMENTATION NOTES 🧚

  • Loko Scheme β€” there is a single unique empty string object, so the returned string will not always be newly allocated. lowkey a plot twist but we respect it πŸ’€

⭐ RETURN VALUES ⭐

Returns a single value; a string. one value, one string, no drama 🌈

πŸ”₯ EXAMPLES πŸ”₯

(vector->string #(#\1 #\2 #\3))  =>  "123"

ate and left no crumbs πŸ˜­πŸ‘‘

πŸ’œ RATIONALE πŸ’œ

R7RS says that this procedure and a few others were added in order to round out the sequence operations. basically they wanted the sequence squad to be complete, and honestly? iconic behavior.

🌸 COMPATIBILITY 🌸

This procedure is unique to R7RS. compatible procedures can be found in SRFI-133 and SRFI-152 β€” so if you're on a different vibe, there's options iykyk πŸ’…

πŸŽ€ ERRORS πŸŽ€

okay so this is the serious part, bestie, pay attention πŸ™ˆ

It is an error to pass the wrong number of arguments, and to pass an argument that is outside its domain. In particular:

  • vector must be a vector of characters supported by the implementation
  • start must be non-negative and not greater than end
  • end must not be greater than the length of vector

The only characters that must be supported by R7RS implementations are the ASCII characters minus NUL. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically. not "fail catastrophically" 😭 that's so real of them

πŸ¦‹ SEE ALSO πŸ¦‹

πŸ‘‘ STANDARDS πŸ‘‘

R7RS

πŸ“ HISTORY πŸ“

This procedure first appeared in R7RS.

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


and that's the whole page, bestie β€” go forth and convert those vectors πŸ’–βœ¨

this slay was brought to you by the 2023-01-27 edition of the Scheme Programmer's Manual, vector->string(3scm) β€” periodt πŸŽ€

πŸ“¦ where this page comes from