1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Survey List/array APIs
|
4 | #
|
5 | # Usage:
|
6 | # demo/survey-list.sh <function name>
|
7 |
|
8 | set -o nounset
|
9 | set -o pipefail
|
10 | set -o errexit
|
11 |
|
12 | source build/dev-shell.sh # python3 in $PATH
|
13 |
|
14 | # Python and JS string and regex replacement APIs
|
15 |
|
16 | insert() {
|
17 | # negative underflow just means insert at the beginning
|
18 | python3 -c '
|
19 | a = ["a", "b", "c", "d", "e"]
|
20 |
|
21 | a.insert(0, "zero")
|
22 | print(a)
|
23 |
|
24 | a.insert(-1, "negative 1")
|
25 | print(a)
|
26 | a.insert(-1, "negative 1 again")
|
27 | print(a)
|
28 |
|
29 | a.insert(-98, "negative 98")
|
30 | print(a)
|
31 |
|
32 | a.insert(-97, "negative 97")
|
33 | print(a)
|
34 | '
|
35 | }
|
36 |
|
37 | "$@"
|