September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1,16 @@
|
|||
# Generate a stream of subsets of the input array
|
||||
def subsets:
|
||||
if length == 0 then []
|
||||
else .[0] as $first
|
||||
| (.[1:] | subsets)
|
||||
| ., ([$first] + .)
|
||||
end ;
|
||||
|
||||
# Generate a stream of non-continuous indices in the range 0 <= i < .
|
||||
def non_continuous_indices:
|
||||
[range(0;.)] | subsets
|
||||
| select(length > 1 and length != 1 + .[length-1] - .[0]) ;
|
||||
|
||||
def non_continuous_subsequences:
|
||||
(length | non_continuous_indices) as $ix
|
||||
| [.[ $ix[] ]] ;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
def count(f): reduce f as $i (0; . + 1);
|
||||
|
||||
count( [range(0;20)] | non_continuous_subsequences)
|
||||
Loading…
Add table
Add a link
Reference in a new issue