Vector
Make a vector
Given a file named “main.scm” with:
When I successfully run scheme main.scm
Then the exit status should be 0.
Make a vector with a fill value
Given a file named “main.scm” with:
When I successfully run scheme main.scm
Then the exit status should be 0.
Convert a vector to a list
Given a file named “main.scm” with:
When I successfully run scheme main.scm
Then the stdout should contain exactly “ABC”.
Get a length of a vector
Given a file named “main.scm” with:
When I successfully run scheme main.scm
Then the stdout should contain exactly “A”.
Examples
value | length |
---|---|
#() | 0 |
#(1) | 1 |
#(1 2) | 2 |
#(1 2 3) | 3 |
(make-vector 3) | 3 |
(make-vector 3 #t) | 3 |
(vector 1 2 3) | 3 |
Get an element in a vector
Given a file named “main.scm” with:
When I successfully run scheme main.scm
Then the stdout should contain exactly “<output>”.
Examples
vector | index | output |
---|---|---|
(vector 65) | 0 | A |
(vector 65 66) | 0 | A |
(vector 65 66) | 1 | B |
(vector 65 66 67) | 0 | A |
(vector 65 66 67) | 1 | B |
(vector 65 66 67) | 2 | C |
Set an element in a vector
Given a file named “main.scm” with:
When I successfully run scheme main.scm
Then the stdout should contain exactly “<output>”.
Examples
vector | index | output |
---|---|---|
(vector 65) | 0 | X |
(vector 65 66) | 0 | XB |
(vector 65 66) | 1 | AX |
(vector 65 66 67) | 0 | XBC |
(vector 65 66 67) | 1 | AXC |
(vector 65 66 67) | 2 | ABX |