Giter VIP home page Giter VIP logo

prem's People

Contributors

riseofthesaber avatar tnthomas avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

riseofthesaber

prem's Issues

Multiplication `*` operator

File evaluators/order3/mult.ts containing evalMult(src: string, node: TreeCursor), which is documented and passes the following tests:

  • The operator multiplies two numeric operands correctly
  • The operator acts once on each element of a Sequence, returning a Sequence of the results
  • The evaluator throws an appropriate EvaluationError if either side of the operator is empty

Modulo `%` operator

File evaluators/order3/mod.ts containing evalMod(src: string, node: TreeCursor), which is documented and passes the following tests:

  • The operator correctly computes the remainder of dividing two numeric operands
  • The operator acts once on each element of a Sequence, returning a Sequence of the results
  • The evaluator throws an appropriate EvaluationError if either side of the operator is empty

Comparison Operators <, <=, ==, !=, >=, >

Comparison operators should be able to use the ArithmeticBinary evaluator under the hood, as comparisons in PREM need to behave a little differently from what you'd expect in a programming language:

Consider the expression output d20 == 20.
If PREM behaved like an ordinary programming language, it would probably coerce the right side to a Sequence and then compare the Sequences by value. Effectively, it would ask "Is the possibility space of a d20 equal to the Sequence {20}?". I don't think this is terribly useful.
Instead, we should distribute the equality test over the die values the same way we would with a math operator, and return the Sequence of results. This way, we're asking "Does a d20 roll a 20?", or in D&D terms, "Did I crit?" Way more useful.

The same goes if we have a Sequence, Dice, or Cards on both sides. In Feng Shui, for instance, you get extra benefits for achieving perfect balance when your yin d6 and your yang d6 roll the same number. This test can be written as output d6 == d6 if we distribute comparisons across sequences.

Division `/` operator

File evaluators/order3/div.ts containing evalDiv(src: string, node: TreeCursor), which is documented and passes the following tests:

  • The operator divides two numeric operands correctly
  • The operator acts once on each element of a Sequence, returning a Sequence of the results
  • The evaluator throws an appropriate EvaluationError if either side of the operator is empty

Not `!` Operator

File evaluators/order2/not.ts containing evalNot(src: string, node: TreeCursor), which is documented and passes the following tests:

  • output !0 yields [ { name: "Output", value: [1] } ]
  • output !1 yields [ { name: "Output", value: [0] } ]
  • output !!4 yields [ { name: "Output", value: [1] } ]
  • Using the Not operator on any nonzero number yields 0
  • The Not operator distributes across Sequences (i.e. output !{1, 0, 5} evaluates to [ { name: "Output", value: [0, 0, 1] } ]

Negative `-` operator

File evaluators/order2/negative.ts containing evalNegative(src: string, node: TreeCursor), which is documented and passes the following tests:

  • output -2 yields [ { name: "Output", value: [-2] } ]
  • output --1 is not allowed (-- is reserved for possible decrement operator)
  • output -0 yields [ { name: "Output", value: [0] } ]
  • Negating a Sequence yields a like Sequence wherein each element of the original Sequence has been negated

Cookies too large

Moderately large outputs overflow the set-cookie header. Ex: output 2d2d6

Parenthetical Expression Evaluator

A file evaluators/order1/parenExpression.ts that contains a function evalParenExpression(src: string, node: TreeCursor), which should pass the following tests:

  • Evaluates by itself with a simple inner expression (such as in output (42))
  • Evaluates inside another expression where the parentheses do not override the default precedence (such as in output (1c2)c4)
  • Overrides default precedence in a simple expression (such as output 1d(2d4))
  • Throws an EvaluatorError if there's nothing between the parentheses

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.