4 ms·
Why is such complication introduced and what are the benefits of it? firstVar || (secondVar=='Bob' && thirdVar==41) seems very clear to me. On the othe
by xlayn 10y ago
Why is such complication introduced and what are the benefits of it?
firstVar || (secondVar=='Bob' && thirdVar==41)
seems very clear to me.
On the other hand JavaScript has always had logic operators... therefore has always been able to perform logic programming.....
From http://www.ecmascript.org/es4/spec/overview.pdf http://www.ecmascript.org/es4/spec/overview.pdf page 18
“&&=” and ”||=” operators
ES4 introduces assignment operators for the logical
“&&” and “||” operators. These assignment operators
are short-circuiting; if the value of the left-hand-
side determines the value of the result then the right-
handside is not evaluated.
- detaro 10y agoThis library can do Prolog-style solving of logical expressions. As in "here is a set of expressions, find me values for the variables that fulfill them." Completely different thing. classical example in the readme: https://github.com/mcsoto/LogicJS#goals https://github.com/mcsoto/LogicJS#goals
- xlayn 10y agoThanks for the reply; "Prolog-style solving of logical expressions in JS" sounds like a better title.
- kaoD 10y ago"Prolog-style solving of logical expressions" is actually called "logic programming". It's the name of the paradigm. https://en.wikipedia.org/wiki/Logic_programming https://en.wikipedia.org/wiki/Logic_programming IMO the title is fine.
- always_good 10y agoNext time please at least click the link before chiming in with a comment. The title was not the problem here.