"def select(f): if f then . else empty end;",
"def sort_by(f): _sort_by_impl(map([f]));",
"def group_by(f): _group_by_impl(map([f]));",
+ "def unique: group_by(.) | map(.[0]);",
};
input: '[{"foo":1, "bar":10}, {"foo":3, "bar":100}, {"foo":1, "bar":1}]'
output: ['[[{"foo":1, "bar":10}, {"foo":1, "bar":1}], [{"foo":3, "bar":100}]]']
+ - title: `unique`
+ body: |
+
+ The `unique` function takes as input an array and produces
+ an array of the same elements, in sorted order, with
+ duplicates removed.
+
+ examples:
+ - program: 'unique'
+ input: '[1,2,5,3,5,3,1,3]'
+ output: ['[1,2,3,5]']
+
- title: `contains`
body: |
[{"a": 4, "b": 1, "c": 3}, {"a": 0, "b": 2, "c": 43}, {"a": 1, "b": 4, "c": 3}, {"a": 1, "b": 4, "c": 14}]
[[{"a": 4, "b": 1, "c": 3}], [{"a": 0, "b": 2, "c": 43}], [{"a": 1, "b": 4, "c": 14}, {"a": 1, "b": 4, "c": 3}]]
[[{"a": 1, "b": 4, "c": 14}, {"a": 0, "b": 2, "c": 43}], [{"a": 4, "b": 1, "c": 3}, {"a": 1, "b": 4, "c": 3}]]
+
+unique
+[1,2,5,3,5,3,1,3]
+[1,2,3,5]