summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorStephen Dolan <mu@netsoc.tcd.ie>2012-09-18 23:32:24 +0100
committerStephen Dolan <mu@netsoc.tcd.ie>2012-09-18 23:32:24 +0100
commit5863160112ac8b50f8b7b7da60044a78f8f261de (patch)
treed6f4514de03f4bfa1e042a3d893c58e5d9927be7 /docs
parentfbf7bc835bfa96800411dc9e7014544779060225 (diff)
Implement the 'add' builtin promised by the docs' examples.
Diffstat (limited to 'docs')
-rw-r--r--docs/content/3.manual/manual.yml37
1 files changed, 37 insertions, 0 deletions
diff --git a/docs/content/3.manual/manual.yml b/docs/content/3.manual/manual.yml
index 417432b4..10998dce 100644
--- a/docs/content/3.manual/manual.yml
+++ b/docs/content/3.manual/manual.yml
@@ -321,6 +321,43 @@ sections:
input: '[[1,2], "string", {"a":2}, null]'
output: [2, 6, 1, 0]
+ - title: `map(x)`
+ body: |
+
+ For any filter `x`, `map(x)` will run that filter for each
+ element of the input array, and produce the outputs a new
+ array. `map(.+1)` will increment each element of an array of numbers.
+
+ `map(x)` is equivalent to `[.[] | x]`. In fact, this is how
+ it's defined.
+
+ examples:
+ - program: 'map(.+1)'
+ input: '[1,2,3]'
+ output: ['[2,3,4]']
+
+ - title: `add`
+ body: |
+
+ The filter `add` takes as input an array, and produces as
+ output the elements of the array added together. This might
+ mean summed, concatenated or merged depending on the types
+ of the elements of the input array - the rules are the same
+ as those for the `+` operator (described above).
+
+ If the input is an empty array, `add` returns `null`.
+
+ examples:
+ - program: add
+ input: '["a","b","c"]'
+ output: ["abc"]
+ - program: add
+ input: '[1, 2, 3]'
+ output: [6]
+ - program: add
+ input: '[]'
+ output: ["null"]
+
- title: `tonumber`
body: |