Re: Quickest way to find out if a sequence is/isn't empty?
- Posted by jimcbrown (admin) Oct 14, 2013
- 1409 views
What would be the quickest way to verify if a sequence is/isn't empty? This especially applies to sequences of considerable sizes.
What I'm trying to explain, is that if a sequence contains data, I don't want the code to iterate through the whole sequence to verify that it ISN'T empty.. I'm guessing not length(mySequence) (or length(mySequence)=0) wouldn't be the quickest one, as it would presumably count through the whole sequence and THEN find out that it isn't empty.
I've also used equal({}, mySequence), but I'm kind of guessing that that also would run through the whole sequence before finding out that it isn't empty.
Regards, ZNorQ aka Kenneth
length(mySequence) is the fastest. length() doesn't count the elements, it just references the existing count (so it's like accessing mySequence[0] where mySequence[0] is always an integer).