September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1 @@
[4,3,2,1,1,2,3,4] | unique

View file

@ -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];