mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-28 00:46:45 +01:00
84 lines
1.7 KiB
Plaintext
84 lines
1.7 KiB
Plaintext
print([])
|
|
print([1, 2, 3])
|
|
print([1, '2', 3, ])
|
|
print([1, [2, 3], 4])
|
|
print([1, [2, [3, 4]], 5])
|
|
|
|
let a := [1, 2, 3]
|
|
print(a[2])
|
|
print(a?.[2])
|
|
print(a?.2)
|
|
print(a?.[7])
|
|
print(a?.7)
|
|
print([1, 2, 3][2], )
|
|
print([1, [2, [3, 4], ], 5][2][2][2])
|
|
print([1, [2, [3, 4], ], 5]?.2?.2?.2)
|
|
print([1, [2, [3, 4], ], 5]?.[2]?.[2]?.[2])
|
|
print([1, [2, [3, 4], ], 5]?.7?.4?.2)
|
|
print([1, [2, [3, 4], ], 5]?.[7]?.[4]?.[2])
|
|
print([1, [2, [3, 4]], 5][2][2][2] + 1)
|
|
print([1, [2, [3, 4, ], ], 5, ].2.2.2)
|
|
|
|
print('------')
|
|
let b := [1, 2, [1,2,3]]
|
|
b[2] := 4
|
|
print(b[1])
|
|
print(b[2])
|
|
print(b[3])
|
|
b[3][3] := 8
|
|
print(b)
|
|
|
|
print('------')
|
|
|
|
print(arrayPushBack([1,2,3], 4))
|
|
print(arrayPushFront([1,2,3], 0))
|
|
print(arrayPopBack([1,2,3]))
|
|
print(arrayPopFront([1,2,3]))
|
|
print(arraySort([3,2,1]))
|
|
print(arrayReverse([1,2,3]))
|
|
print(arrayReverseSort([3,2,1]))
|
|
print(arrayStringConcat([1,2,3], ','))
|
|
|
|
print('-----')
|
|
let arr := [1,2,3,4] // we don't modify arr
|
|
print(arr)
|
|
arrayPushBack(arr, 5)
|
|
print(arr)
|
|
arrayPushFront(arr, 0)
|
|
print(arr)
|
|
arrayPopBack(arr)
|
|
print(arr)
|
|
arrayPopFront(arr)
|
|
print(arr)
|
|
arraySort(arr)
|
|
print(arr)
|
|
arrayReverse(arr)
|
|
print(arr)
|
|
arrayReverseSort(arr)
|
|
print(arr)
|
|
|
|
print('------')
|
|
print(has(arr, 0))
|
|
print(has(arr, 2))
|
|
print(has(arr, 'banana'))
|
|
print(has('banananas', 'banana'))
|
|
print(has('banananas', 'foo'))
|
|
print(has(['1', '2'], '1'))
|
|
|
|
print(indexOf([1,2,3], 1)) // 1
|
|
print(indexOf([1,2,3], 2)) // 2
|
|
print(indexOf([1,2,3], 3)) // 3
|
|
print(indexOf([1,2,3], 4)) // 0
|
|
|
|
print(arrayCount(x -> x > 2, [1,2,3,4,5])) // 3
|
|
|
|
print('------')
|
|
let c := [1,2,3]
|
|
print(c[1], c[2], c[3], c[4])
|
|
print(c[-1], c[-2], c[-3], c[-4])
|
|
|
|
print('------')
|
|
print('a' in ['a', 'b', 'c'])
|
|
print('d' in ['a', 'b', 'c'])
|
|
print('a' in [])
|