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
8
votes
5 answers

Need guidance towards evaluative boolean logic tree

I can't seem to find a pointer in the right direction, I am not even sure what the terms are that I should be researching but countless hours of googling seem to be spinning me in circles, so hopefully the collective hive of intelligence of Stack…
8
votes
2 answers

Evaluate() in VBA

Hi and welcome to the Evaluate() mystery The MSDN Office Developer Reference (2013) Documentation says: Using square brackets (for example, "[A1:C5]") is identical to calling the Evaluate method with a string argument. So, I have ran a very…
user2140173
8
votes
1 answer

Expression evaluation tree in Haskell

In an exam today I was asked to create an expression evaluation tree in Haskell. Usually the answer is as simple as: data Expr = Value Integer | Add Expr Expr | Sub Expr Expr | Mul Expr Expr And to evaluate it, you…
Matt Williams
  • 1,198
  • 1
  • 10
  • 27
7
votes
3 answers

Convert NSString of a math equation to a value

I would like to know how to evaluate a string representation of an equation as if it were a real equation: if(@"15+14==23") { //True statement... } else { //False statement.... } I want to return "false" because 15+14 does not equal 23. How…
7
votes
1 answer

Undefined behavior inside void expressions

Is a C implementation required to ignore undefined behaviors occurring during the evaluation of void expressions as if the evaluation itself never took place? Considering C11, 6.3.2.2 §1: If an expression of any other type is evaluated as a void…
anol
  • 8,264
  • 3
  • 34
  • 78
7
votes
1 answer

Disturbing order of evaluation

When I work with my favorite containers, I tend to chain operations. For instance, in the well-known Erase–remove idiom: v.erase( std::remove_if(v.begin(), v.end(), is_odd), v.end() ); From what I know of the order of evaluation, v.end() (on the…
YSC
  • 38,212
  • 9
  • 96
  • 149
6
votes
9 answers

Left to right expression evaluation

In C# is it guaranteed that expressions are evaluated left to right? For example: myClass = GetClass(); if (myClass == null || myClass.Property > 0) continue; Are there any languages that do not comply?
6
votes
1 answer

Arithmetic Expression Evaluation using Reverse Polish Notation (RPN)

A mathematical expression is usually expressed in infix notation. For evaluation purposes, we can change it to postfix (reverse polish) notation (using algorithms like Shunting-Yard) and then evaluate the postfix notation using stack. I found out…
5
votes
4 answers

Operator precedence versus order of evaluation

A friend asked me to explain the difference between operator precedence and order of evaluation in simple terms. This is how I explained it to them :- Let's take an example - int x; int a = 2; int b = 5; int c = 6; int d = 4; x = a * b / (c +…
Kushagr Jaiswal
  • 191
  • 1
  • 9
5
votes
2 answers

When and how are VLAs evaluated in sizeof expressions?

The C Standard has this language: 6.5.3.4 The sizeof and _Alignof operators Semantics The sizeof operator yields the size (in bytes) of its operand, which may be an expression or the parenthesized name of a type. The size is determined from the…
chqrlie
  • 131,814
  • 10
  • 121
  • 189
5
votes
2 answers

How to unload an assembly in .NET Core / make it collectible?

How can I unload an assemlby in .NET Core ? Note: .NET Core does not support AppDomains. Background: I have to evaluate user-generated VisualBasic expressions dynamically. So to do this, I dynamically compile the expressions with Roslyn. I…
Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442
5
votes
3 answers

How to evaluate the code provided by user?

I need to process some user-provided code on the server using PHP. The code is about to cover some very basic programming capabilities, for example: variables, literals, (preferably) functions, and some associated operations. An option is to use the…
user13324009
5
votes
2 answers

Prolog: show truth table for arbitrary expression using is/2 for some subexpressions

Suppose I have some expressions that look like a /\ b \/ c. I would like to generate the truth table for this, something like: a | b | c | a /\ b \/ c ---+----+----+-------------+- F | F | F | F F | F | T | T F | T | F | F F | T | T |…
Daniel Lyons
  • 22,421
  • 2
  • 50
  • 77
5
votes
2 answers

Writing String evaluation function

I'm trying to write a String evaluation function i.e. evaluate("4 + 1") ; // returns 5 evaluate("4 + 1 + 3") ; // returns 8 evaluate("4 + 1 * 3") ; // returns 7 (not 15) The operators are + - / and * My initial though was to use regular…
Gandalf StormCrow
  • 25,788
  • 70
  • 174
  • 263
4
votes
1 answer

Undefined Behavior when using Comma Operator in C++

I am trying to learn how expression are evaluated in C++. So trying out and reading different examples. Below is the code about which i am unable to understand whether it will produce undefined behavior or not. The code is from here. So i guess…
Jason
  • 36,170
  • 5
  • 26
  • 60
1
2
3
12 13