Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: Allowed moves database chessboard, knight to many entries.... Date: Wed, 12 Aug 2020 12:12:34 +0100 Organization: A noiseless patient Spider Lines: 44 Message-ID: <87h7t886e5.fsf@bsb.me.uk> References: <73e9271a-a86d-4eb6-9927-9c84d60c9cc6o@googlegroups.com> <19bd3446-2d76-4e6d-a131-ee4a9834c331o@googlegroups.com> <0965b2e8-47ec-42b7-a294-a874d5f176abo@googlegroups.com> <42350bec-28d0-4b85-89db-1aed763e1026o@googlegroups.com> <39f38e8f-f303-4f76-9034-dc51bf49f7d6o@googlegroups.com> <5eec68a9-bbe9-48d9-895c-91cc335b9439o@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: reader02.eternal-september.org; posting-host="83ec15541f21d3ee705dc86ab8efc171"; logging-data="14773"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19mHbU3XT3PUUaR5Qo+DJhjRcKmdFhHGZ4=" Cancel-Lock: sha1:+NCgcZQLY/sy2yfrjToywjuUEb4= sha1:wOj2F7QZ+8ECsmM0qcRtXFn45Lo= X-BSB-Auth: 1.9b839c507b4c08d140cf.20200812121234BST.87h7t886e5.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:38716 Jonas Thörnvall writes: > Den onsdag 12 augusti 2020 kl. 09:40:48 UTC+2 skrev Jonas Thörnvall: >> Den onsdag 12 augusti 2020 kl. 00:57:32 UTC+2 skrev luserdroog: >> > On Tuesday, August 11, 2020 at 4:33:36 PM UTC-5, Evertjan. wrote: >> > > wrote on 11 Aug 2020 in comp.lang.javascript: >> > > >> > > > Honestly Evertjan i find >> > > > Math.random() < 0.5 >> > > > giving a boolean weird enough >> > > >> > > The result of any comparison must be a boolean. >> > > >> > > Programming needs some honest brain exercise. >> > > >> > >> > Without going too far out on a limb, I support the use of relational >> > operators to produce boolean values. (I also like implicit conversion >> > from 0 and 1.) >> >> if (Math.random<0.5) {holder=false;} (you meant to call the function: if (Math.random()<0.5) {holder=false;} > Not holder=Math.random<0.5 > It is both syntactical and semantical gibberish Your code is not equivalent to assignment you dislike. You'd need something like if (Math.random()<0.5) holder=false; else holder=true; But what do you think the "Math.random() < 0.5" in the "if" is if not an expression yielding a true/false result? And if that is what it is, why not allow the result to be assigned just like the result of any pther expression? Many decades ago, before we knew how to do this stuff, there were programming languages that only allowed relations and comparisons in certain positions (the test of an "if" or a "while" etc.) but thankfully those days are long gone. -- Ben.