-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Milestone
Description
Here are plug-in replacements for the existing defs. These replacements use 0-arity filters to effect the recursion, and are ridiculously faster even for arrays of size 10^4. (*)
def _nwise($n):
def nw: if length <= $n then . else .[0:$n] , (.[$n:] | nw) end;
nw;
def _nwise(a; $n): a | _nwise($n);
(*) [[range(0;n)] | _nwise(3)] | length
builtin.jq replacement
n u+s u+s
10,000 23.0s 0.027s
itchyny