-
-
Save charles-dyfis-net/3f596d0aa19f187b80e6ee167dfc55c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[1,2,3] | |
[4,5,6] | |
[7,8,9] | |
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/local/bin/jq -n -f | |
def nwise(stream; $n): | |
foreach (stream, nan) as $x ([]; | |
if length == $n then [$x] else . + [$x] end; | |
if .[-1] | isnan then .[:-1] ## original | |
#if .[-1] | isnan then if (. | length) > 1 then .[:-1] else empty end ## proposed | |
elif length == $n then . | |
else empty | |
end); | |
nwise(inputs; 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# note that not all operating systems allow a shebang line to contain more than two words | |
printf '%s\n' {1..9} | /usr/bin/time -l ./partition.jq -c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment