-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support JQ's index/rindex function #154
Comments
I don't think it's intentional. I'd even guess that anything from jq that's purposely excluded from jaq is documented in the README. For these filters ( # Indexing
def indices($i):
def enumerate:
. as $thing |
if type == "string"
then range(length) | [., $thing[.:.+1]]
else range(length) | [., $thing[.]]
end;
def windowed($size):
if $size <= 0 then empty
else . as $array | range(length - $size + 1) | $array[.:. + $size]
end;
if ["string", "array"] | any(. == ($i | type))
then [[windowed($i | length)] | enumerate | select(.[1] == $i)[0]]
else [enumerate | select(.[1] == $i)[0]]
end;
def index($i): indices($i) | .[0];
def rindex($i): indices($i) | .[-1:][0]; It's not very good, and fails on |
I fixed the error by changing the condition to Anyway I put my implementation of these filters in a PR, with tests copied straight from jq's website: #158 |
Jq has the
index
andrindex
functions which don't seem to be supported in jaq. Is there a specific reason for this? Thank you for your time.The text was updated successfully, but these errors were encountered: