evaluation

PetitParser evaluator not working properly

夙愿已清 提交于 2019-12-11 07:29:55
问题 when I try running this code on pharo, my answers are somewhat off. I try evaluating 1-2+3 but for some reason, it does 1- (2+3) and I do not understand why this is so. Thanks for your time. number := #digit asParser plus token trim ==> [ :token | token inputValue asNumber ]. term := PPUnresolvedParser new. prod := PPUnresolvedParser new. term2 := PPUnresolvedParser new. prod2 := PPUnresolvedParser new. prim := PPUnresolvedParser new. term def: (prod , $+ asParser trim , term ==> [ :nodes |

Order of statement evaluation and variable assignment in MySQL UNIONs

大城市里の小女人 提交于 2019-12-11 07:15:42
问题 Question: In the UNIONized query below, how can I force @col to be assigned before the dependent derived queries are evaluated? Requirement: it needs to be done in one query. CREATE TABLE tbl (col CHAR(1) NOT NULL UNIQUE); INSERT INTO tbl (col) VALUES ('a'), ('b'), ('c'), ('d'), ('e'), ...; -- Now, for some value of "col", fetch that record and the -- immediately preceding and following records as ordered by "col" -- -- If you care to test this, be sure to SET @col := NULL before --

How does the outermost evaluation strategy evaluate partial application of a function and application of a curried function

元气小坏坏 提交于 2019-12-11 06:47:33
问题 Programming in Haskell by Hutton says When evaluating an expression, in what order should the reductions be performed? One common strategy, known as innermost evaluation , is to always choose a redex that is innermost, in the sense that it contains no other redex. If there is more than one innermost redex, by convention we choose the one that begins at the leftmost position in the expression. Another common strategy for evaluating an expression, dual to innermost evaluation, is to always

Validating a string mathematical expression

℡╲_俬逩灬. 提交于 2019-12-11 06:30:11
问题 Guys I am working on a system that evaluates string mathematical expression. my class to carry out the calculation public Double Calculate(string argExpression) { //get the user passed string string ExpressionToEvaluate = argExpression; //pass string in the evaluation object declaration. Expression z = new Expression(ExpressionToEvaluate); //command to evaluate the value of the **************string expression var result = z.Evaluate(); Double results = Convert.ToDouble(result.ToString());

Modelica Evaluation Order

无人久伴 提交于 2019-12-11 03:34:17
问题 I can't really find any answer in the Modelica specification so ill ask you guys. The specification states that A tool is free to solve equations, reorder expressions and to not evaluate expressions if their values do not influence the result (e.g. short-circuit evaluation of Boolean expressions). If-statements and if-expressions guarantee that their clauses are only evaluated if the appropriate condition is true, but relational operators generating state or time events will during continuous

Consecutive calls/evaluations in a form?

回眸只為那壹抹淺笑 提交于 2019-12-11 02:01:59
问题 Hey guys, simple question... Working with XLISP to write a program, but I've seemed to run into a simple fundamental problem that I can't seem to work around: perhaps someone has a quick fix. I'm trying to write an if statement who's then-clause evaluates multiple forms and returns the value of the last. In example: (setq POSITION 'DINING-ROOM) (defun LOOK (DIRECTION ROOM) ... ) (defun SETPOS (ROOM) ... ) (defun WHERE () ... ) (defun MOVE (DIRECTION) (if (not(equal nil (LOOK DIRECTION

Controlling Prolog variable value selection

给你一囗甜甜゛ 提交于 2019-12-11 00:34:22
问题 Inspired by an earlier question I tried to implement something that would enumerate the possibilities for a boolean expression. However, I'm having trouble with variable choice. Here's my intended outcome: ?- eval(X^Y, R). R = 0^0; R = 0^1; R = 1^0; R = 1^1; no. Here's my code: :- op(200, yfx, ^). split(V, R) :- var(V), R = 0. split(V, R) :- var(V), R = 1. split(X ^ Y, XP ^ YP) :- split(X, XP), split(Y, YP). This already doesn't do what I want even for this simple case: ?- split(Y, R). R = 0

Enforcing the number of decimal places when printing results

ε祈祈猫儿з 提交于 2019-12-11 00:31:54
问题 A different exercise. This one asked to evaluate the value of x for x-2=ln(x). There are two approaches (A and B) - one makes use of the given equation and yields the smaller solution (x1). The other approach uses e**(x-2)=x and yields the other solution (x2). Program plots the graphical solution and then queries for initial value input. Then it evaluates x using appropriate approaches. Approach A requires initial condition lesser than x2, approach B requires initial condition greater than x1

Partial evaluation with pyparsing

戏子无情 提交于 2019-12-10 18:38:20
问题 I need to be able to take a formula that uses the OpenDocument formula syntax, parse it into syntax that Python can understand, but without evaluating the variables, and then be able to evaluate the formula many times with changing valuables for the variables. Formulas can be user input, so pyparsing allows me to both effectively handle the formula syntax, and clean user input. There are a number of good examples of pyparsing available, but all the mathematical ones seem to assume that one

How do I evaluate a symbol returned from a function in Scheme?

南笙酒味 提交于 2019-12-10 15:47:15
问题 I'm refamiliarizing myself with Scheme and I've hit a problem that is probably reflecting a fundamental misunderstanding on my part. Say I do the following in Scheme (using Guile in this case but it's the same in Chicken): > (define x 5) > x 5 > (string->symbol "x") x > (+ 5 (string->symbol "x")) <unnamed port>:45:0: In procedure #<procedure 1b84960 at <current input>:45:0 ()>: <unnamed port>:45:0: In procedure +: Wrong type: x > (symbol? (string->symbol "x")) #t > (+ 5 x) ; here x is