Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1 @@
|
|||
[4,3,2,1,1,2,3,4] | unique
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
def removeAllButFirst:
|
||||
|
||||
# The hash table functions all expect the hash table to be the input.
|
||||
|
||||
# Is x in the hash table?
|
||||
def hashed(x):
|
||||
(x|tostring) as $value
|
||||
| .[$value] as $bucket
|
||||
| $bucket and (.[$value] | index([x]));
|
||||
|
||||
# Add x to the hash table:
|
||||
def add_hash(x):
|
||||
(x|tostring) as $value
|
||||
| .[$value] as $bucket
|
||||
| if $bucket and ($bucket | index([x])) then .
|
||||
else .[$value] += [x]
|
||||
end;
|
||||
|
||||
reduce .[] as $item
|
||||
( [[], {}]; # [array, hash]
|
||||
if .[1] | hashed($item) then .
|
||||
else [ (.[0] + [$item]), (.[1] | add_hash($item)) ]
|
||||
end)
|
||||
| .[0];
|
||||
Loading…
Add table
Add a link
Reference in a new issue