Path: csiph.com!goblin3!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: passing a set of numbers to a function Date: Fri, 05 Feb 2016 15:42:15 +0000 Organization: A noiseless patient Spider Lines: 31 Message-ID: <87oabvkvu0.fsf@bsb.me.uk> References: <19679ed0-c594-4f7e-817c-a72bd5c10411@googlegroups.com> <22041181.SJtjrm8m6U@PointedEars.de> <87r3gso59h.fsf@bsb.me.uk> <1603158.xI32ru06Pi@PointedEars.de> <58b65993-5943-4f8e-a4e2-9e97bb1feea3@googlegroups.com> <7de86700-d479-49ff-819f-8187843a09b8@googlegroups.com> <87twlnkyye.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="2983"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX196qSpWqfAobq6o2WyaugyJni16FTbELNY=" Cancel-Lock: sha1:Dij7x3QfGDN/MoH6JBAP3kcbWMQ= sha1:vhNJim4FF6tgqn0Vy2tuShEjOZs= X-BSB-Auth: 1.807399c40d2be70e674e.20160205154215GMT.87oabvkvu0.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:29546 ram@zedat.fu-berlin.de (Stefan Ram) writes: > Ben Bacarisse writes: >>To implement something like ("a" | "b") & ~"c" you parse the expression >>and build a matching functions as you go. Given something like > > One also might replace every »"string"« by »(x==="string")«. Yes, though that was not the intended semantics. With your interpretation the example has a redundant clause. > This would give: > > ((x==="string") | (x==="string")) & ~(x==="string") > > . One then can also replace some operators: > > ((x==="string") || (x==="string")) && !(x==="string") > > . Finally, one could then call »Function« with > > new Function( 'x', '((x==="string") || (x==="string")) && !(x==="string")' ) > > if there were no problems with security and > incorrect inputs. As you say, it's possible to do this sort of thing via string manipulation, but I've found it to be fiddly in practice. -- Ben.