# expression<TAB>canonical JSON result
nil null
true true
42 42
1.5 1.5
"hello" "hello"
[1, 2, 3] [1,2,3]
{a: 1, b: "two"} {"a":1,"b":"two"}
{b: "two", a: 1} {"a":1,"b":"two"}
1 + 2 * 3 7
2 ** 3 8
1 + 0.5 1.5
1 == 1.0 true
1 < 1.5 true
false and unknown false
true or unknown true
nil ?? "fallback" "fallback"
true ? "yes" : "no" "yes"
[1, 2, 3][-1] 3
[1, 2, 3, 4][1:3] [2,3]
2 in [1, 2, 3] true
"hello" startsWith "he" true
"hello" matches "^h" true
1..3 [1,2,3]
let x = 2; x * 3 6
upper("mise") "MISE"
split("a,b", ",") ["a","b"]
split("a;b", ";") ["a","b"]
map([1, 2, 3], {# * 2}) [2,4,6]
filter([1, 2, 3], {# > 1}) [2,3]
find([1, 2, 3], {# > 1}) 2
sort([3, 1, 2]) [1,2,3]
sort(keys({a: 1, b: 2})) ["a","b"]
len({a: 1, b: 2}) 2
int("42") 42
float("1.5") 1.5
float(5) 5
string(42) "42"
bitand(14, 11) 10
bitushr(-5, 2) 4611686018427387902
0x2A 42
0x_2A 42
0o52 42
0b101010 42
1_000_000 1000000
.5 0.5
2 not in [1, 3] true
"name" not in {other: 1} true
{"display-name": "mise"}["display-name"] "mise"
[1, 2,] [1,2]
{a: 1,} {"a":1}
max(5, 7) 7
min(5, 7) 5
max(1.5, 2) 2
max(9007199254740992, 9007199254740993) 9007199254740993
min(9007199254740993, 9007199254740992) 9007199254740992
type(max(1.5, 2)) "int"
abs(-5) 5
abs(-1.5) 1.5
ceil(1.5) 2
floor(1.5) 1
round(1.5) 2
round(-1.5) -2
type(ceil(2)) "float"
max([1, [5, 3]], 4) 5
mean([1, 2, 3, 4]) 2.5
median([4, 1, 3, 2]) 2.5
join(["a", "b", "c"], "-") "a-b-c"
join(["a", "b"]) "ab"
first([1, 2, 3]) 1
first([]) null
last([1, 2, 3]) 3
last([]) null
take([1, 2, 3], 2) [1,2]
take([1, 2], 9) [1,2]
reverse([1, 2, 3]) [3,2,1]
uniq([1, 2, 1, 3, 2]) [1,2,3]
concat([1, 2], [3], []) [1,2,3]
flatten([1, [2, [3]], 4]) [1,2,3,4]
count([true, false, true]) 2
count([1, 2, 3], {# > 1}) 2
sum([1, 2, 3]) 6
sum([1, 2.5, 3]) 6.5
sum([1, 2, 3], {# * 2}) 12
reduce([1, 2, 3], #acc + #) 6
reduce([1, 2, 3], #acc + #, 10) 16
reduce([1, 2, 3], {let doubled = # * 2; #acc + doubled}, 10) 22
[1, 2, 3] | reduce(#acc + #, 10) 16
[1, 2, 3] | reduce({#acc + #}, 10) 16
type(nil) "nil"
type(42) "int"
type(1.5) "float"
type([1]) "array"
get([1, 2], 1) 2
get([1, 2], -1) 2
get([1, 2], 9) null
get({a: 1}, "a") 1
get({a: 1}, "missing") null
toBase64("Hello World") "SGVsbG8gV29ybGQ="
fromBase64("SGVsbG8gV29ybGQ=") "Hello World"
sortBy(toPairs({a: 1, b: 2}), {#[0]}) [["a",1],["b",2]]
fromPairs([["a", 1], ["b", 2]]).b 2
max(9007199254740992, 9007199254740993) 9007199254740993
min(9007199254740993, 9007199254740992) 9007199254740992
get([1, 2, 3], -1) 3
repeat("foo", 3) "foofoofoo"
replace("foo,bar,baz,goo", ",", "-", 2) "foo-bar-baz,goo"
sort([10.0, 2.0, 1.0]) [1,2,10]
reduce([1, 2, 3], {#acc + #}, 10) 16
[1, 2, 3] | reduce({#acc + #}, 10) 16
"a,b,c" | split(",") ["a","b","c"]
1e3 1000
1.2e-4 0.00012
.5e+2 50
1_000.5_0e-2 10.005
map([10, 20, 30], #index) [0,1,2]
reduce([10, 20, 30], #acc + #index, 0) 3
b"abc" "YWJj"
b'\xff\x00' "/wA="
b"ÿ" "w78="
len(b"abc") 3
b"abc"[0] 97
b"abc"[-1] 99
get(b"abc", 0) 97
get(b"abc", -1) 99
b"abc"[1:] "YmM="
b"abc"[99:] ""
b"abc"[-99:] "YWJj"
b"abc"[2:1] ""
b"abc" == b"abc" true
b"abc" != b"abd" true
string(b"abc") "[97 98 99]"
toJSON(b"abc") "\"YWJj\""
if true { 1 } else { 2 } 1
if false { 1 } else { 2 } 2
if false { 1 } else if true { 2 } else { 3 } 2
if true { let x = 2; x * 3 } else { 0 } 6
duration("1h30m") 5400000000000
type(duration("1h")) "time.Duration"
duration("1h30m").Seconds() 5400
duration("1h30m").Minutes() 90
duration("1h30m").String() "1h30m0s"
duration("500ms").String() "500ms"
duration("500us").String() "500µs"
duration("1ns").String() "1ns"
duration("-1500us").String() "-1.5ms"
date("2023-08-14") "2023-08-14T00:00:00Z"
date("2023-08-14").String() "2023-08-14 00:00:00 +0000 UTC"
type(date("2023-08-14")) "time.Time"
date("2023-08-14").Year() 2023
date("2023-08-14").Month() 8
date("2023-08-14").Weekday().String() "Monday"
date("2023-08-14").YearDay() 226
timezone("UTC").String() "UTC"
type(timezone("UTC")) "time.Location"
date("2023-08-14").In(timezone("Europe/Zurich")).Hour() 2
date("2023-08-14") + duration("24h") "2023-08-15T00:00:00Z"
date("2023-08-15") - date("2023-08-14") 86400000000000
date("24.11.1987 20:30", "02.01.2006 15:04", "Europe/Zurich") "1987-11-24T20:30:00+01:00"
date("2023-08-14").Format("2006-01-02") "2023-08-14"
date("2023-08-04T15:06:07Z").Format("1 2 _2 3 4 5 -0700 Z0700 MST") "8 4 4 3 6 7 +0000 Z UTC"
date("2023-08-04T15:06:07+02:30").Format("-0700 Z0700 MST") "+0230 +0230 +0230"
date("2023-08-04").In(timezone("Europe/Zurich")).Format("MST -0700 Z0700") "CEST +0200 +0200"
date("4 8 2023 3:6:7 +0230", "2 1 2006 3:4:5 -0700") "2023-08-04T03:06:07+02:30"
date("4 Aug 2023 UTC", "2 Jan 2006 MST") "2023-08-04T00:00:00Z"
duration("1h") < duration("2h") true
get(fromPairs([[1, "one"], [2, "two"]]), 2) "two"
fromPairs([[1, "one"]])[1] "one"
1 in fromPairs([[1, "one"]]) true
keys(fromPairs([[1, "one"]])) [1]
values(fromPairs([[1, "one"]])) ["one"]
len(fromPairs([[1, "one"]])) 1
string(fromPairs([[10, "ten"], [2, "two"], [1, "one"]])) "map[1:one 2:two 10:ten]"
string(fromPairs([[true, "yes"], [false, "no"]])) "map[false:no true:yes]"
string(fromPairs([[2.5, "b"], [1.5, "a"]])) "map[1.5:a 2.5:b]"
trimPrefix("abc") "abc"
trimSuffix("abc") "abc"
len(split("abc", ",", 0)) 0
len(splitAfter("a,b", ",", 0)) 0
splitAfter("a,b", ",", -1) ["a,","b"]
5 / 2 2.5
5 / 2.0 2.5
string(1 / 0) "+Inf"
2 ^ 3 8
2 ^ -1 0.5
9223372036854775807 + 1 -9223372036854775808
-9223372036854775807 - 2 9223372036854775807
9223372036854775807 * 2 -2
[1, 2][2:1] []
[1, 2][99:] []
[1, 2][-99:] [1,2]
[1, 2][:-99] []
duration("1h") * 2 7200000000000
2 * duration("1h") 7200000000000
(-9223372036854775807 - 1) % -1 0
let start = 1; let end = 3; start..end [1,2,3]
1 + 1..2 + 2 [2,3,4]
let index = 1; [10, 20, 30][index] 20
let start = 1; let end = 3; [10, 20, 30, 40][start:end] [20,30]
let end = 2; [10, 20, 30][:end] [10,20]
let start = 1; b"abcd"[start:] "YmNk"
let start = 1; let end = 3; "abcd"[start:end] "bc"
"héllo"[1:3] "é"
len("é🙂") 2
sum([9223372036854775807, 1]) -9223372036854775808
abs(-9223372036854775807 - 1) -9223372036854775808
uniq([1, 1.0, 2, 2.0]) [1,2]
len(fromPairs([[1, "int"], [1.0, "float"]])) 2
get(fromPairs([[1, "int"], [1.0, "float"]]), 1) "int"
get(fromPairs([[1, "int"], [1.0, "float"]]), 1.0) "float"
1 in fromPairs([[1.0, "float"]]) false
groupBy(1..9, # % 2)[0] [2,4,6,8]
groupBy(1..3, # > 1)[true] [2,3]
groupBy(1..3, # > 1 ? nil : "")[nil] [2,3]
groupBy([1, 1.0], #)[1] [1]
groupBy([1, 1.0], #)[1.0] [1]
string(date("2023-08-04T15:06:07.12Z")) "2023-08-04 15:06:07.12 +0000 UTC"
date(timezone("Europe/Zurich"), "2023-08-14").Location().String() "Europe/Zurich"
date(timezone("Europe/Zurich"), "2023-08-14").IsDST() true
date(timezone("Europe/Zurich"), "2023-01-14").IsDST() false
date("2023-01-31").AddDate(0, 1, 0) "2023-03-03T00:00:00Z"
date("2023-08-14").Add(duration("90m")) "2023-08-14T01:30:00Z"
date("2023-08-15").Sub(date("2023-08-14")) 86400000000000
date("2023-08-14").Before(date("2023-08-15")) true
date("2023-08-15").After(date("2023-08-14")) true
date("2023-08-14").Equal(date("2023-08-14T02:00:00+02:00")) true
date("2023-08-14").Compare(date("2023-08-15")) -1
date("2023-08-14T01:29:31Z").Round(duration("1h")) "2023-08-14T01:00:00Z"
date("2023-08-14T01:59:31Z").Truncate(duration("1h")) "2023-08-14T01:00:00Z"
date("2023-08-14T00:00:00+02:00").UTC() "2023-08-13T22:00:00Z"
duration("-90m").Abs() 5400000000000
duration("89m").Round(duration("1h")) 3600000000000
duration("90m").Round(duration("1h")) 7200000000000
duration("-90m").Round(duration("1h")) -7200000000000
duration("119m").Truncate(duration("1h")) 3600000000000
date("2023-01-02T03:04:05.12+02:30").Format("__2 002 05.000 05.999999999 -07 -070000 -07:00:00 Z07 Z070000 Z07:00:00") " 2 002 05.120 05.12 +02 +023000 +02:30:00 +02 +023000 +02:30:00"
date("2023 002 03:04:05.120 +02:30:00", "2006 002 15:04:05.000 -07:00:00") "2023-01-02T03:04:05.12+02:30"
date("0001-01-01").IsZero() true
date("2023-08-14").Location().String() "UTC"
date("2023-08-14T01:29:31Z").Round(duration("7h")) "2023-08-14T00:00:00Z"
date("2023-01-02T03:04:05.12Z").Format("05,000 05,999999999 Z07:00:00 Z070000") "05,120 05,12 Z Z"
date("2023-01-02T03:04:05,12Z", "2006-01-02T15:04:05,99Z07:00") "2023-01-02T03:04:05.12Z"
date("2023-01-02T03:04:05+02:30:15", "2006-01-02T15:04:05-07:00:00").Format("-07:00:00") "+02:30:15"
date(timezone("Europe/Zurich"), "2023-03-25T12:00:00", "2006-01-02T15:04:05").AddDate(0, 0, 1).Format("2006-01-02T15:04:05Z07:00") "2023-03-26T12:00:00+02:00"
date("2023-08-14T01:29:31+02:00").Round(duration("1h")).Format("15:04:05-07:00") "01:00:00+02:00"
date("4 Aug 2023 PST", "2 Jan 2006 MST").Format("MST -0700") "PST +0000"
date(timezone("America/New_York"), "2023-03-12T01:30:00", "2006-01-02T15:04:05").Add(duration("1h")).Format("2006-01-02T15:04:05Z07:00") "2023-03-12T03:30:00-04:00"
date(timezone("America/New_York"), "2023-03-12T01:31:00", "2006-01-02T15:04:05").Round(duration("1h")).Format("2006-01-02T15:04:05Z07:00") "2023-03-12T03:00:00-04:00"
date(timezone("America/New_York"), "2023-03-12T03:30:00", "2006-01-02T15:04:05").Truncate(duration("2h")).Format("2006-01-02T15:04:05Z07:00") "2023-03-12T01:00:00-05:00"
date("0001-01-01T01:00:00+01:00").IsZero() true
date("2023-01-02T03:04:05.120Z").Format("5.000 5.999") "5.120 5.12"
date("2023-01-02T03:04:05.120Z", "2006-01-02T15:04:5.000Z07:00") "2023-01-02T03:04:05.12Z"
date("2023-08-14").Local().Location().String() "Local"
timezone("Local").String() "Local"
date("2023-08-14", "2006-01-02", "Local").Location().String() "Local"