Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #29729

Re: General compute language, syntax question

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.javascript
Subject Re: General compute language, syntax question
Date 2016-02-29 15:11 +0000
Organization A noiseless patient Spider
Message-ID <87povflffk.fsf@bsb.me.uk> (permalink)
References <615c2e25-d8b6-4803-a157-b7ba748d1c71@googlegroups.com> <93318b24-7815-4801-bea2-309e79c6f5dd@googlegroups.com> <1df59a2c-61fd-4431-885c-70f12d15f678@googlegroups.com>

Show all headers | View raw


jonas.thornvall@gmail.com writes:
<snip>
> I mean how utterly fucking stupid must one be to come up with a
> solution that require the programmer to check if the array[index] is
> empty what index? Index for 0 it doesn't exist? Or do they require me
> to loop thru an empty list how do you do that?

It's possible that you are using the wrong data type for the job (an
array is very different from a list, so if you need a list an array
might be a bad fit).

Anyway, if you are using the new ECMAScript you might find that

  !array.some(() => true)

does what you want or even (depending on how you handle deleted
elements) the much cheaper array.length == 0.  For example, if you use
push/pop/ shift/unshift to add and remove elements you'll find an
empty "list" has length zero.

-- 
Ben.

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

General compute language, syntax question jonas.thornvall@gmail.com - 2016-02-29 05:45 -0800
  Re: General compute language, syntax question jonas.thornvall@gmail.com - 2016-02-29 05:58 -0800
    Re: General compute language, syntax question jonas.thornvall@gmail.com - 2016-02-29 06:25 -0800
      Re: General compute language, syntax question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-02-29 15:11 +0000
  Re: General compute language, syntax question Martin Honnen <mahotrash@yahoo.de> - 2016-02-29 15:47 +0100
  Re: General compute language, syntax question "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-03-02 18:14 -0800
    Re: General compute language, syntax question jonas.thornvall@gmail.com - 2016-03-03 00:26 -0800

csiph-web