Skip to content
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

max\min against arrays #351

Open
samer1977 opened this issue May 27, 2024 · 1 comment · May be fixed by #357
Open

max\min against arrays #351

samer1977 opened this issue May 27, 2024 · 1 comment · May be fixed by #357
Labels
enhancement New feature or request

Comments

@samer1977
Copy link

Hi,

Sorry maybe my brain still thinks the other way but how would you solve this problem:
bazaarvoice/jolt#700

I cant think of a way without having to create custom recursive max\min as in:

def max_array(array)

if(size($array)==0)
null
else if(size($array)==1)
$array[0]

else max($array[0],max_array($array[1:]))

vs

{

"minPrice": min([for(.prices).price])
"minPrice": max([for(.prices).price])

}

Thanks

@larsga larsga added the enhancement New feature or request label May 27, 2024
@larsga
Copy link
Collaborator

larsga commented May 27, 2024

You're right that there is no other way at the moment. max() and min() should perhaps also have single-argument versions that accept an array.

@catull catull linked a pull request May 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants