File: vector-copy

package info (click to toggle)
scheme9 2025.08.12-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,080 kB
  • sloc: lisp: 16,752; ansic: 11,869; sh: 806; makefile: 237; sed: 6
file content (23 lines) | stat: -rw-r--r-- 1,021 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
S9 LIB  (vector-copy vector)                           ==>  vector
        (vector-copy vector integer1)                  ==>  vector
        (vector-copy vector integer1 integer2)         ==>  vector
        (vector-copy vector integer1 integer2 object)  ==>  vector

Returns a copy of the given vector. When INTEGER1 and INTEGER2
are specified, extract a subvector starting at position INTEGER1
and ending at INTEGER2 (excluding the INTEGER2'th element). When
INTEGER2 is omitted, it defaults to the length of the input vector.

(vector-copy '#(a b c d e f))      ==>  #(a b c d e f)
(vector-copy '#(a b c d e f) 3)    ==>  #(d e f)
(vector-copy '#(a b c d e f) 2 5)  ==>  #(c d e)

When the 'end' argument (INTEGER2) is larger than the length of
the input vector, then extra slots will be added to the fresh copy:

(vector-copy '#(a b c d e f) 4 7)  ==>  #(e f #<unspecific>)

An extra argument (OBJECT) may be added to fill extra slots with
a specific value:

(vector-copy '#(a b c d e f) 5 10 'x)  ==>  #(f x x x x)