cortex-js / compute-engine

An engine for symbolic manipulation and numeric evaluation of math formulas expressed with MathJSON
https://cortexjs.io
MIT License
375 stars 47 forks source link

"Or" Logical Operator issue? #73

Closed Frizzled closed 1 year ago

Frizzled commented 1 year ago

The "And" operator works as expected:

    let expr = ce.box(["And", ["Equal", "True", "False"], ["Equal", "True", "True"]])
    console.log(expr.evaluate().valueOf()) // false

    expr = ce.box(["And", ["Equal", "True", "True"], ["Equal", "True", "True"]])
    console.log(expr.evaluate().valueOf()) // true

However, the "Or" operator does not:

    let expr = ce.box(["Or", ["Equal", "True", "False"], ["Equal", "True", "True"]])
    console.log(expr.evaluate().valueOf()) // true

    expr = ce.box(["Or", ["Equal", "True", "True"], ["Equal", "True", "False"]])
    console.log(expr.evaluate().valueOf()) // true

    expr = ce.box(["Or", ["Equal", "True", "False"], ["Equal", "True", "False"]])
    console.log(expr.evaluate().valueOf()) // true

    expr = ce.box(["Or", ["Equal", "True", "True"], ["Equal", "True", "True"]])
    console.log(expr.evaluate().valueOf()) // true
svitrol commented 1 year ago

I was browsing definitions and found this: obrazek

https://github.com/cortex-js/compute-engine/blob/main/src/compute-engine/latex-syntax/dictionary/definitions-logic.ts obrazek

probably not resolving situation above, but still wrong and it is operator or issue.

arnog commented 1 year ago

@svitrol please feel free to submit a PR. I'd be happy to review and merge it.

svitrol commented 1 year ago

@arnog sorry for not fixing this earlier :D but was focused on logical operators and didn't notice obrazek latexTrigger: '\operator{False}', -> prases as True latexTrigger: '\mathsf{F}', -> parses as True

arnog commented 1 year ago

Good catch. Fixed.