Added flatten and flatten(x) functions

Fix #415.
This commit is contained in:
Santiago Lapresta authored and Nicolas Williams committed 2014-06-16 17:03:05 -05:00
1 parent f741074267
commit 061a604a2a
3 files changed
+36

No files matched your search

+22
View File
@@ -796,6 +796,28 @@ sections:
input: '[]'
output: ["true"]
- title: "`flatten`"
body: |
The filter `flatten` takes as input an array of nested arrays,
and produces a flat array in which all arrays inside the original
array have been recursively replaced by their values. You can pass
an argument to it to specify how many levels of nesting to flatten.
examples:
- program: flatten
input: '[1, [2], [[3]]]'
output: ["[1, 2, 3]"]
- program: flatten(1)
input: '[1, [2], [[3]]]'
output: ["[1, 2, [3]]"]
- program: flatten
input: '[[]]'
output: ["[]"]
- program: flatten
input: '[{"foo": "bar"}, [{"foo": "baz"}]]'
output: ['[{"foo": "bar"}, {"foo": "baz"}]']
- title: "`range`"
body: |