Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.javascript Subject: Re: Lazy programmers guide to blizz Date: Tue, 5 Nov 2019 11:06:31 +0100 Lines: 90 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net +MI3bpglNwD7AndGtT8KLACPAShW08fCPyhw8ABXpKfBCKqJ6H Cancel-Lock: sha1:vnKrWsmNfY71jZBhS5Oz32lfmGM= In-Reply-To: Content-Language: en-US Xref: csiph.com comp.lang.javascript:37692 On 01.11.19 14:27, Jonas Thörnvall wrote: > Den fredag 1 november 2019 kl. 11:04:17 UTC+1 skrev Arno Welzel: >> On 01.11.19 08:50, Jonas Thörnvall wrote: >>> It so boring writing if intervals using < > or > < >>> And hard to read >>> Why not simplify >>> >>> if(A inside.interval(144-159)) >>> if (A outside.interval(144-159)) >>> >>> Maybe there already is interval functions in javascript? >>> >>> Alteratively for the operator fixated >>> if (144< A <159) >>> if (144> A >159) >> >> Hmmm... >> >> >> A inside.interval(144-159) >> >> vs. >> >> A >= 144 && A <= 160 >> >> And you find the first one really simpler? I don't. >> >> For example: does inside.interval() mean ">=" and "<=" or ">" and "<"? >> This is not clear when looking at the code. >> >> But if you prefer this, just create your own function - assuming, that >> the interval means including the lower and upper limit: >> >> function between(x, min, max) { >> return x >= min && x <= max; >> } >> >> >> >> >> -- >> Arno Welzel >> https://arnowelzel.de JFTR: This is a signature which is usally not cited. The delimiter can be recognized by the trailing space: "-- ". Real usenet clients will automatically handle this. You should consider using a NNTP server and a usenet client instead of Google Groups. > Well i would definitly interpretate that the boundaries are inside, because they can't be outside. Including the boundaries does not mean "outside". For example: x>=10 && x<=20 x can be 10 or 20 and is still inside the range x>10 && x<20 x must be more than 10 and less then 20 to be inside the range. And furthermore: x inside(a-b) All programming languages I know (shell scripts, C, C++, C#, PHP, ECMAScript, Java etc.) see "a-b" as "a minus b". And interpreting "-" as "," depending on the context is just stupid since this would require a additional code in some cases, for example if a or b are not absolute values or variables but expressions: x inside((a-1)-b) And reading this is even worse: the first "-" is "minus" and the second "-" would be the "range" operator. Before you think about how to add new syntax to a language you should first learn the basics. YACC/LEX may be a good starting point: http://dinosaur.compilertools.net -- Arno Welzel https://arnowelzel.de