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


Groups > comp.lang.javascript > #29729

Re: General compute language, syntax question

Path csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.javascript
Subject Re: General compute language, syntax question
Date Mon, 29 Feb 2016 15:11:27 +0000
Organization A noiseless patient Spider
Lines 22
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>
Mime-Version 1.0
Content-Type text/plain
Injection-Info mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="13245"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18uNag1zBC4UhS1H2+f2UUS0fSG53N9WT0="
Cancel-Lock sha1:pKfkdoqnF9zilcmXC74v7eEy+xc= sha1:U+nossT6TmaakadMmRiEfPeELE8=
X-BSB-Auth 1.610f63625efae04c9a78.20160229151127GMT.87povflffk.fsf@bsb.me.uk
Xref csiph.com comp.lang.javascript:29729

Show key headers only | 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