-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
length, numel, count, strlen #1939
Comments
I don't understand why there should be a separate |
The idea is that if you're argument is something that needs to be consumed in order to count the number of elements (say a task or a stream), then if you call length and have no more elements left you're going to be rather unhappy. |
I think the case of a non-rewindable iterable argues for calling the function |
Hmm. That feels like a serious rathole. |
Decision: |
We seem to have resolved that |
|
Related to #1454. |
|
Saying that this will confound Matlab users is a bit of a stretch. What's a use case where someone from Matlab would actually use |
Ok, since we have had this behaviour for a long time, we have been confounding Matlab users for a long time. :-) |
|
I agree unless A is of type rectangle. Then that length makes sense. "width" would be the min(size(A)). |
I agree that makes sense, but it seems too quirky to allow in a language with arbitrary rank tensors. |
Totally agree it is a bad idea in general. I should have been more clear. My minor point was that length may not be the best name. I think 'count' is less confusing but at this point I don't really care which way it goes. I expected 'length' to return nrow(array) since length of a shape is usually the size of one dimension. |
I would be fine with |
See discussion here: #1916. There are a couple of things going on here.
numel
.count
should be a reducer for giving the number of elements in a collection.length
givecount
that way.count
in place ofstrlen
?There may be other things to consider here.
The text was updated successfully, but these errors were encountered: