Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #32361
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Handling multiple results from combinations |
| Date | 2017-01-26 23:21 +0100 |
| Organization | PointedEars Software (PES) |
| Message-ID | <1771290.oMNUckLgyt@PointedEars.de> (permalink) |
| References | <B9OdnUTUM9EuUBvFnZ2dnUU7-dnNnZ2d@westnet.com.au> <Beu5S02dqSiYFwq1@invalid.uk.co.demon.merlyn.invalid> <874e7957-7f2f-48f1-8083-e3b653f46797@googlegroups.com> |
Michael Haufe (TNO) wrote:
> Dr J R Stockton wrote:
>> You could maybe concatenate the booleans in a string as illustrated by
>> var Q = "F" + +(1==1) + +(1==2) + +(1!=2)
>> then write functions for each case - function F101() { ... } for that -
>> and then merely execute window[Q]() // !!! untested. Lo, not an
>> "if" in sight.
>
> Might as well use a Bit Mask then [1] ...
A bit mask is something slightly different. A bit _Map_ (sic) and bitwise
operations is what I would use as a start, with names for the bits to keep
it easily maintainable. However, Ben’s string approach is interesting too,
as it has the advantage over bitwise operations that it works for more than
32 selectors¹, basically an infinite number of them (same principle as
arbitrary-precision arithmetic).
_______
¹ This is not obvious from what you referred to: Bitwise operations are
limited to 32-bit integers (ES 2016, § 12.13), so even though you can
store integers precisely natively up to including 2⁵³ (ES 2016,
§ 20.1.2.6), you cannot reasonably use all of those in bitwise
operations.
Apropos powers of 2, since last year (2016) ECMAScript has an
exponentiation operator: 2 ** 53 === Math.pow(2, 53), specified in
ES 2016, § 20.2.2.26 and 12.7.3.4. I found that out by accident in the
DevTools console this week when testing possible solutions and being
surprised that the typo “**” did not result in a SyntaxError exception.
--
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
Handling multiple results from combinations Andrew Poulos <ap_prog@hotmail.com> - 2017-01-24 14:44 +1100
Re: Handling multiple results from combinations Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-24 05:34 +0100
Re: Handling multiple results from combinations Andrew Poulos <ap_prog@hotmail.com> - 2017-01-24 16:54 +1100
Re: Handling multiple results from combinations Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-24 07:14 +0100
Re: Handling multiple results from combinations "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-23 22:31 -0800
Re: Handling multiple results from combinations "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-24 11:27 +0100
Re: Handling multiple results from combinations "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-24 16:41 -0800
Re: Handling multiple results from combinations "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-25 11:17 +0100
Re: Handling multiple results from combinations "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-25 05:19 -0800
Re: Handling multiple results from combinations "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-25 06:25 -0800
Re: Handling multiple results from combinations "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-25 17:37 +0100
Re: Handling multiple results from combinations "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-25 08:47 -0800
Re: Handling multiple results from combinations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-24 14:22 +0000
Re: Handling multiple results from combinations Doc O'Leary <droleary@2015usenet1.subsume.com> - 2017-01-24 20:17 +0000
Re: Handling multiple results from combinations "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-24 16:47 -0800
Re: Handling multiple results from combinations Dr J R Stockton <reply1700@merlyn.demon.co.uk.invalid> - 2017-01-25 22:45 +0000
Re: Handling multiple results from combinations "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-25 17:53 -0800
Re: Handling multiple results from combinations Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-26 23:21 +0100
csiph-web