Questions tagged [expression-evaluation]

Anything related to expression evaluation, i.e. the process of determining the value of an expression in running code.

Anything related to expression evaluation, i.e. the process of determining the value of an expression in running code.

189 questions
4
votes
1 answer

Defining constants and operators in Irony

I'm new to Irony and the whole language implementation shebang, so I've been playing around with the ExpressionEvaluator sample that comes with the Irony source, which seems to (almost) suit my needs for a project I'm working on. However, I would…
bernhof
  • 6,219
  • 2
  • 45
  • 71
4
votes
1 answer

Function evaluation conflicting with other effects in statement

I would like to clarify my understanding of evaluation order in Fortran. Let's say I have a Stack type with methods pop and push_back. If I execute the following code: call stack%push_back(1) call stack%push_back(3) call stack%push_back(stack%pop()…
mcocdawc
  • 1,748
  • 1
  • 12
  • 21
4
votes
0 answers

How to evaluate without unnecessary parentheses in Julia?

I have a case struct which holds an expression with the type of SymbolicUtils.Term{Bool}. Also I have defined rules from SymbolicUtils library which takes these cases as input and simplifies them. In order to simplify these cases the form should be…
patoglu
  • 401
  • 4
  • 16
4
votes
2 answers

ReSharper bug? Incorrect "expression is always true"

I believe I have found a bug in ReSharper. Suppose I have code as follows: int[] someArray = new int[10]; while (someArray != null) { //perhaps some other usage of someArray here, but not assigning it. SomeMethod(ref someArray ); } If…
JBSnorro
  • 6,048
  • 3
  • 41
  • 62
4
votes
1 answer

R, data.table: Sum all columns whose names are stored in a vector

From a data.table d such as for example require(data.table) d = data.table(a = 1:4, b = 11:14, c = 21:24, group = c(1,1,2,2)) I would like to sum all variables which names are stored in the vector varsToSum by unique values of group. varsToSum =…
Remi.b
  • 17,389
  • 28
  • 87
  • 168
4
votes
3 answers

strange behavior of std::cout in c++

#include int a(int &x) { x = -1; return x; } int main () { int x = 5; std::cout << a(x) << " " << x << std::endl; } Why output is "-1 5"? PS: compiler is: i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple…
4
votes
1 answer

Algorithm for parsing expressions in python?

I have next algorithm for parsing expressions in Python: def parse(strinput): for operator in ["+-", "*/"]: depth = 0 for p in range(len(strinput) - 1, -1, -1): if strinput[p] == ')': depth += 1 elif strinput[p] == '(': depth…
Tommz
  • 3,393
  • 7
  • 32
  • 44
3
votes
1 answer

Lisp / Scheme : Evaluating nested empty list/cons : (())

I'm using this Lisp compiler for testing There is one things that I don't get it : If an empty list () evaluate to itself : (format t "~:a" ()) ;; => () why do evaluating several nested empty list () don't evaluate to an empty list ? (format t…
3
votes
1 answer

ANTLR : expression evaluator, division and pow

I'm trying to write a grammar to evaluate expressions. I've started with the given example on the ANTLR website (it manage +,- and *). I added the division. But I would like to notify user if he tries to divide by 0. Moreover, I would like to add…
eouti
  • 5,338
  • 3
  • 34
  • 42
3
votes
2 answers

Racket "eval" a datum

I'm trying to level up on metaprogramming in Racket and realized I don't know how to take a datum and simply "eval" it. If I have (for ((x '(("Five" (+ 2 3)) ("Twelve" (* 6 2)) ("Three" (- (/ 21 3) 4))))) (displayln…
George Mauer
  • 117,483
  • 131
  • 382
  • 612
3
votes
6 answers

C multiple variable assignment

I'm first year student in Software Engineering and in my last task I used (chain assignment) multiple assignment of values. The lecturer claims that it is illegal to assign values in this way. X = Y = Z; (The three variables are declared in the…
0xAlon
  • 123
  • 1
  • 1
  • 10
3
votes
2 answers

Evaluation order of lambda functions in Racket

Currently working through the Racket Guide at https://docs.racket-lang.org and reading up on lambda functions. The explanation of their usefulness is lucid, but I am not sure I quite grasp the order in which such functions are evaluated. Consider…
user242007
  • 286
  • 3
  • 13
3
votes
1 answer

Evaluation with Continuation Passing Style without the Cont Monad

I have a task: to write a function evalCPS which evaluates expressions formalized by the ADT below, using Continuation Passing Style but without Cont Monad or similar stuff. data Expr a = Expr a :+: Expr a | Expr a :/: Expr a …
3
votes
2 answers

Evaluate an operation in a dataframe's context

I'm working with formulas in a package, and I'd like to remove all non-numeric terms. My problem is that, since the base formula may contain operations, I cannot evaluate some terms directly. Here is a reprex: datax=mtcars op = c("mpg", "log(mpg)",…
Dan Chaltiel
  • 7,811
  • 5
  • 47
  • 92
3
votes
2 answers

How to deal with the implicit 'cat' operator while building a syntax tree for RE(use stack evaluation)

I am trying to build a syntax tree for regular expression. I use the strategy similar to arithmetic expression evaluation (i know that there are ways like recursive descent), that is, use two stack, the OPND stack and the OPTR stack, then to…
1 2
3
12 13