Lengths of Lists

resolvent's picture

What is the command which returns the length of a list?
i.e. length of [1,2,3] is 3 ?

More importantly, please tell me where in the help menu this command is listed. Thank you.

Comments

nops

try nops (number of operands). I would have expected it to be under ?list, but I see it isn't (in v. 10), which does seems like a serious omission.

see also

It's listed in the SeeAlso section (of ?list, which actually goes to ?set). Usually it is worthwhile to skim those to see whether anything looks useful. Admittedly 'nops' is not self explanatory, but for something used so frequently, a short name is appreciated.

nops

I found the use of this word kinda funny when I first began using Maple but now it seems perfectly suited. Being an assembly language programmer who frequently uses "nop" for non-executable fill within my code, when I first saw it in Maple I found myself trying to correlate it's usage within Maple in the same way until I actually read the documentation associated with it.

resolvent's picture

Nops

How could "nops" be considered anywhere NEAR "perfectly suited"?
In C++ and Java, probably the two most common computer programming
languages on earth, "length" or "listlength" or something very similar to these
and obvious is used to return the length of a list or an array.

Robert Israel's picture

nops versus length

I think "nops" has been in Maple from the very beginning, and you're not likely to get it changed now: better get used to it, if you're going to do any Maple programming. It's not just for lists, it's for any Maple object: nops returns the number of operands. "length" is already a Maple function, which returns the total length of an object. Mupad, BTW, also uses "nops". Maybe some other CAS's do too. Most computer languages, I think, don't deal so often with expressions that have an arbitrary number of operands.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}