OILS / demo / survey-list.sh View on Github | oils.pub

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