Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/Hash-from-two-arrays/Jq/hash-from-two-arrays-1.jq
Normal file
12
Task/Hash-from-two-arrays/Jq/hash-from-two-arrays-1.jq
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# hash(keys) creates a JSON object with the given keys as keys
|
||||
# and values taken from the input array in turn.
|
||||
# "keys" must be an array of strings.
|
||||
# The input array may be of any length and have values of any type,
|
||||
# but only the first (keys|length) values will be used;
|
||||
# the input will in effect be padded with nulls if required.
|
||||
def hash(keys):
|
||||
. as $values
|
||||
| reduce range(0; keys|length) as $i
|
||||
( {}; . + { (keys[$i]) : $values[$i] });
|
||||
|
||||
[1,2,3] | hash( ["a","b","c"] )
|
||||
6
Task/Hash-from-two-arrays/Jq/hash-from-two-arrays-2.jq
Normal file
6
Task/Hash-from-two-arrays/Jq/hash-from-two-arrays-2.jq
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
jq -n -f Hash_from_two_arrays.jq
|
||||
{
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
}
|
||||
5
Task/Hash-from-two-arrays/Jq/hash-from-two-arrays-3.jq
Normal file
5
Task/Hash-from-two-arrays/Jq/hash-from-two-arrays-3.jq
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"1": 10,
|
||||
"2": 20,
|
||||
"3": 30
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue