September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
17
Task/Search-a-list/Jq/search-a-list.jq
Normal file
17
Task/Search-a-list/Jq/search-a-list.jq
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
["a","b","c"] | index("b")
|
||||
# => 1
|
||||
|
||||
["a","b","c","b"] | index("b")
|
||||
# => 1
|
||||
|
||||
["a","b","c","b"]
|
||||
| index("x") // error("element not found")
|
||||
# => jq: error: element not found
|
||||
|
||||
# Extra task - the last element of an array can be retrieved
|
||||
# using `rindex/` or by using -1 as an index into the array produced by `indices/1`:
|
||||
["a","b","c","b","d"] | rindex("b")
|
||||
# => 3
|
||||
|
||||
["a","b","c","b","d"] | indices("b")[-1]
|
||||
# => 3
|
||||
Loading…
Add table
Add a link
Reference in a new issue