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

min() and max() do not support strings #829

Closed
JennaSys opened this issue Sep 28, 2022 · 3 comments
Closed

min() and max() do not support strings #829

JennaSys opened this issue Sep 28, 2022 · 3 comments
Assignees

Comments

@JennaSys
Copy link
Collaborator

I didn't see an exception listed in the docs, but the min() and max() translations are currently using the JS Math.min() and Math.max() which only support numbers, whereas the Python version also supports string types in the iterable.

// Maximum of n numbers
export function max (nrOrSeq) {
    return arguments.length == 1 ? Math.max (...nrOrSeq) : Math.max (...arguments);       
};

// Minimum of n numbers
export function min (nrOrSeq) {
    return arguments.length == 1 ? Math.min (...nrOrSeq) : Math.min (...arguments);       
};

If used with an iterable containing strings, the translated max/min returns NaN. There are of course workarounds, but this should work the same as CPython or be a documented exception.

@JennaSys
Copy link
Collaborator Author

Also consider issue #305 for supporting a key function.

@JennaSys
Copy link
Collaborator Author

JennaSys commented Jul 5, 2024

Added in dev_3.9.3 branch to be released in v3.9.3

@JennaSys JennaSys self-assigned this Jul 5, 2024
@JennaSys
Copy link
Collaborator Author

Merged to master on PR #876

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant