RosettaCodeData/Task/Extensible-prime-generator/Jq/extensible-prime-generator-1.jq
2023-07-01 13:44:08 -04:00

9 lines
309 B
Text

# Recent versions of jq include the following definition:
# until/2 loops until cond is satisfied,
# and emits the value satisfying the condition:
def until(cond; next):
def _until:
if cond then . else (next|_until) end;
_until;
def count(cond): reduce .[] as $x (0; if $x|cond then .+1 else . end);