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