Git Product home page Git Product logo

Comments (2)

wiebecommajonas avatar wiebecommajonas commented on July 30, 2024 2

Boolean expressions are entirely possible., but like @drocta mentioned, you will have to drop the == operator for now.

And because Noq does not support conditional rule application (yet), you will have to do it manually.

Here I wrote a short example of what it could look like:

and_f :: and(bool(false), bool(_)) = bool(false)
and_t :: and(bool(true), bool(true)) = bool(true)

or_f :: or(bool(false), bool(false)) = bool(false)
or_t :: or(bool(true), bool(_)) = bool(true)

not_f :: not(bool(false)) = bool(true)
not_t :: not(bool(true)) = bool(false)
not_and :: not(and(bool(A), bool(B))) = or(not(A), not(B))
not_or :: not(or(bool(A), bool(B))) = and(not(bool(A)), not(bool(B)))

eq_f :: eq(bool(true), bool(false)) = bool(false)
eq_t :: eq(bool(A), bool(A)) = bool(true)

basic_comm :: B(X, Y) = B(Y, X)

eq(bool(true), bool(false)) {
	eq_f | all
}

eq(and(bool(false), bool(true)), bool(false)) {
	and_f | all
	eq_t | all
}

eq(not(or(bool(false), bool(true))), and(not(bool(true)), bool(true))) {
    not_or | all
    not_f | all
    not_t | all
    basic_comm | 1
    and_f | all
    eq_t | all
}

from noq.

drocta avatar drocta commented on July 30, 2024

disclaimer: I'm also not confident of my understanding of the syntax, but, just by what the stuff is supposed to do:
I imagine that after running true | all that you would have the expression bool(0) == not(false)
and then after running false | all you would have the expression bool(0) == not(bool(1))
and then bool_eq | all would fail to match anything, because bool(0) == not(bool(1)) is not of the form bool(A) == bool(B).
Instead, I believe you would want to run things in this order (again, I'm unsure of the syntax, and am only commenting on the logic of what you are doing, not the right way to express it syntactically)

someNameGoesHere :: true == not(false) {
    not | all
    true | all
    bool_eq | all
}

so that you would start with true == not(false),
then after not | all you would have true == true,
and then after true | all you would have bool(0) == bool(0)
and then after bool_eq | all you would have 0 == 0 , which I imagine is what you were trying to get.
(I believe all of the | all in what I said, other than the true | all, could be replaced with | 0 because there is only one place where it applies.)

(I don't know whether == is an allowed infix operator in this language)

from noq.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.