Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Scheme Programming/Vector Operations

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Creating Vectors > (vector 1 2 3 4 5) #(1 2 3 4 5) > (define v (vector 1 2 3 4 5)) #<unspecified> Vector Manipulation Accessing Elements > (vector-ref (vector 1 2 3 4 5) 3) 4 > (vector? (vector 1 2 3 4 5)) #t Vector-ref takes two arguments, a vector and a valid index of the vector, and returns the element at that index. Notice how the vector is zero indexed. I.e. the first element of a vector is referenced by number 0. Modifying Elements > (define my-vector (vector 1 2 3 4 5)) #<unspecified> > (vector-set! my-vector 3 'a) #<unspecified> > my-vector #(1 2 3 a 5)