From: Nicolas Williams Date: Mon, 2 Dec 2013 18:19:23 +0000 (-0600) Subject: Add index and rindex builtins X-Git-Tag: jq-1.4~76^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b37ce20c2ad9e742cf2a67ab73a1818ad1c9e254;p=jq Add index and rindex builtins --- diff --git a/builtin.c b/builtin.c index aa3c888..087741f 100644 --- a/builtin.c +++ b/builtin.c @@ -676,6 +676,8 @@ static const char* const jq_builtins[] = { "def from_entries: map({(.key): .value}) | add;", "def with_entries(f): to_entries | map(f) | from_entries;", "def reverse: [.[length - 1 - range(0;length)]];", + "def index(i): .[i][0];", + "def rindex(i): .[i][-1:][0];", };