-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Uri edited this page Jul 11, 2021
·
14 revisions
(import (otus algebra))
Vector is a one-dimensional array. Vector can be declared using several ways:
- by it's values which can be any applicable number:
> [1 2 3 4 5]
#(1 2 3 4 5)
> [0 -3 3/7 16+4i 7.12 (inexact 7.12) 123456789876543213546576666777757575757444]
#(0 -3 3/7 16+4i 178/25 7.12 123456789876543213546576666777757575757444)
- As a copy of existing vector:
> (define v [1 2 3 4 5])
> (print v)
#(1 2 3 4 5)
> (copy v)
#(1 2 3 4 5)
- As an uninializied vector of N elements.
> (vector 14)
#(0 0 0 0 0 0 0 0 0 0 0 0 0 0)
- As a vector of
0
s:
> (zeros 14)
#(0 0 0 0 0 0 0 0 0 0 0 0 0 0)
- As a vector of
1
s:
> (ones 42)
#(1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
- As a vector of a same any applicable value:
> (fill (vector 17) -33)
#(-33 -33 -33 -33 -33 -33 -33 -33 -33 -33 -33 -33 -33 -33 -33 -33 -33)