vector-length(3scm)

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

πŸ’– vector-length (3scm) πŸ’–

okay so bestie, welcome to the Scheme Programmer's Manual β€” yes, the actual one β€” and today's main character is vector-length, a tiny little procedure that literally just tells you how many things are in your vector. no cap, that's the whole gig. she's iconic, she's simple, she ate πŸ’…


✨ NAME ✨

vector-length β€” the length of a vector πŸŽ€

🫢 LIBRARY 🫢

lowkey you gotta import her first, and there are options depending on which Scheme vibe you're on:

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

🌸 SYNOPSIS 🌸

(vector-length vector)

that's it. that's the whole call. slay.

πŸ’œ DESCRIPTION πŸ’œ

She returns β€” as an exact integer object β€” the number of elements in vector. 🧚

and here's the tea: the length of a vector is fixed. it's not growing, it's not shrinking, it's not going through a phase. it is what it is, periodt.

πŸ”₯ IMPLEMENTATION NOTES πŸ”₯

So like, all extant implementations use fixnums to represent vector lengths β€” every single one, fr fr β€” but that's not required. so don't come for anyone who does it differently, okay? πŸ™ˆ

⭐ RETURN VALUES ⭐

Returns a single value, and that value is the length of the vector. one value, one job, main character energy πŸ‘‘

🌈 EXAMPLES 🌈

(vector-length '#(1 2 3))
          => 3

look at her go 😭 three elements in, three out. math is mathing.

πŸ¦‹ APPLICATION USAGE πŸ¦‹

Okay so vector-length sometimes shows up in code that destructures vectors β€” you know the vibe β€” but ngl, in those cases it might be better to use a pattern matching library such as (chibi match). just a lil tip from me to you 🫢

πŸ’€ COMPATIBILITY πŸ’€

Apart from error handling, this procedure is the same in all Scheme reports. same queen, different eras. πŸ’…

πŸ™ˆ ERRORS πŸ™ˆ

She can raise exceptions with the following condition types, so keep an eye out:

  • &assertion (R6RS) β€” the wrong number of arguments was passed, or an argument was outside its domain. you did too much, 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. 😭 yeah. catastrophically. be careful out there.

πŸ‘‘ SEE ALSO πŸ‘‘

go read those next, iykyk πŸ“

πŸŽ€ STANDARDS πŸŽ€

R4RS, IEEE Scheme, R5RS, R6RS, R7RS

she's certified in all of them. versatile icon.

πŸ’– 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!! πŸ¦‹ this lil beauty is from 2021-01-03, and the source/version on the footer is the Scheme Programmer's Manual (vector-length(3scm)) β€” mwah, love u, go count some vectors πŸ’–βœ¨

πŸ“¦ where this page comes from