diff options
author | Santiago Lapresta <santiago.lapresta@gmail.com> | 2014-05-30 00:45:16 +0200 |
---|---|---|
committer | Nicolas Williams <nico@cryptonector.com> | 2014-06-07 21:53:03 -0500 |
commit | 01f676041db158a87ad98ccd7443dce7a85757f2 (patch) | |
tree | 75ecce4153df0d9a1f47f9b8015e34cf9e689213 | |
parent | 6856ab8a69505e76939ae4926cb7f7eea7156eb6 (diff) |
Added `join` function
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
-rw-r--r-- | builtin.c | 1 | ||||
-rw-r--r-- | docs/content/3.manual/manual.yml | 14 |
2 files changed, 15 insertions, 0 deletions
@@ -703,6 +703,7 @@ static const char* const jq_builtins[] = { "def nulls: select(type == \"null\");", "def values: arrays, objects, booleans, numbers, strings;", "def scalars: select(. == null or . == true or . == false or type == \"number\" or type == \"string\");", + "def join(x): reduce .[] as $i (\"\"; . + (if . == \"\" then $i else x + $i end));", }; #undef LIBM_DD diff --git a/docs/content/3.manual/manual.yml b/docs/content/3.manual/manual.yml index 801b4b21..e64de245 100644 --- a/docs/content/3.manual/manual.yml +++ b/docs/content/3.manual/manual.yml @@ -1075,6 +1075,20 @@ sections: input: '"a, b,c,d, e"' output: ['["a","b,c,d","e"]'] + - title: `join` + body: | + + Joins the array of elements given as input, using the + argument as separator. It is the inverse of `split`: that is, + running `split("foo") | join("foo")` over any input string + returns said input string. + + examples: + - program: 'join(", ")' + input: '["a","b,c,d","e"]' + output: ['"a, b,c,d, e"'] + + - title: `recurse` body: | |