1
1
mirror of https://github.com/wader/fq.git synced 2024-12-23 13:22:58 +03:00
fq/pkg/interp/funcs.jq.test
2022-12-05 20:52:27 +01:00

74 lines
1.2 KiB
Plaintext

map(expr_to_path | path_to_expr)
[".", ".a", ".a[0]", ".a[123].bb", ".[123].a", ".[123][123].a", ".\"b b\"", ".\"a \\\\ b\"", ".\"a \\\" b\""]
[".", ".a", ".a[0]", ".a[123].bb", ".[123].a", ".[123][123].a", ".\"b b\"", ".\"a \\\\ b\"", ".\"a \\\" b\""]
.[] | group
[[1], [1,2], [1,2,2], [1,2,2,3]]
[[1]]
[[1],[2]]
[[1],[2,2]]
[[1],[2,2],[3]]
.[] | count
[[1], [1,2], [1,2,2,2], [1,2,2,2,3]]
[[1,1]]
[[1,1],[2,1]]
[[1,1],[2,3]]
[[1,1],[2,3],[3,1]]
.[] | count_by(.%2)
[[1], [1,2], [1,2,2,2], [1,2,2,2,3]]
[[1,1]]
[[0,1],[1,1]]
[[0,3],[1,1]]
[[0,3],[1,2]]
.[] | streaks
[[], [1], [1,1], [1,1,2], [1,1,2,2], [1,2,2,1]]
[]
[[1]]
[[1,1]]
[[1,1],[2]]
[[1,1],[2,2]]
[[1],[2,2],[1]]
.[] | delta
[[], [1], [1,2], [1,2,2,2], [1,2,2,2,3]]
[]
[]
[1]
[1,0,0]
[1,0,0,1]
.[] | delta_by(.a+.b)
[[], [1], [1,2], [1,2,2,2], [1,2,2,2,3]]
[]
[]
[3]
[3,4,4]
[3,4,4,5]
streaks_by(.a)
[{"a":1},{"a":1},{"a":2}]
[[{"a":1},{"a":1}],[{"a":2}]]
.[] as [$input, $size] | $input | chunk($size)
[[[], 1], [[], 2], [[1], 1], [[1], 2], [[1,2], 1], [[1,2], 2], [[1,2,3,4], 2], [[1,2,3,4], 3], ["", 1], ["", 2], ["1", 1], ["1", 2], ["12", 1], ["12", 2], ["1234", 2], ["1234", 3]]
[]
[]
[[1]]
[[1]]
[[1],[2]]
[[1,2]]
[[1,2],[3,4]]
[[1,2,3],[4]]
[]
[]
["1"]
["1"]
["1","2"]
["12"]
["12","34"]
["123","4"]