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

Open
JennaSys opened this issue Sep 28, 2022 · 1 comment
Open

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

JennaSys opened this issue Sep 28, 2022 · 1 comment

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.

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

No branches or pull requests

1 participant