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
1
vote
1 answer

Mathematical expression evaluator which incorporates units of measure

Similar to this question but different. Lots of good answers there, but none do Units of Measure. How about a .NET compatible (even through COM, if necessary) mathematical expression evaluator which incorporates units of measure? I've tried NCalc…
1
vote
3 answers

Why does the execution order of function call arguments not follow the specified order?

I am reading the book of CPP-Concurrency-In-Action-2ed-2019. In chapter 5.3.2, the author gives a simple example: #include void foo(int a, int b) { std::cout << a << ", " << b << std::endl; } int get_num() { static int i = 0; …
f1msch
  • 509
  • 2
  • 12
1
vote
1 answer

lambda binding upon call is causing issue in my generated code

As the author of Pythonizer, I'm translating some perl code to python that defines a function FETCH in 2 different packages in the same source file, like: package Env; sub FETCH {...} package Env::Array; sub FETCH {...} and my generated code needs…
snoopyjc
  • 621
  • 4
  • 11
1
vote
1 answer

C ternary operator branches evaluation?

I always assumed the ternary operator in C did not evaluate the branch that failed the test. Why does it in this case? a is less than b so only c should be assigned to 1, d should remain 2. Thank your for tips and suggestions. I have compiled with…
lucmobz
  • 151
  • 1
  • 6
1
vote
1 answer

Dynamic logical expression parser/evaluation in Java/Apex

End-user can define condition selections/logical expressions in String like below: String expression = "((1 OR 2) AND 6 AND (3 OR 4)) AND 5"; or String expression = "(1 AND 2 AND 3 AND 4) OR (5 AND 6)"; or etc... and the values of 1, 2, 3, ... are…
1
vote
2 answers

Why is *ptr = (*ptr)++ Undefined Behavior

I am trying to learn how to explain the cause of(if any) of undefined behavior in the following cases(given below). int i = 0, *ptr = &i; i = ++i; //is this UB? If yes then why according to C++11 *ptr = (*ptr)++; //i think this is UB but i am unable…
Jason
  • 36,170
  • 5
  • 26
  • 60
1
vote
1 answer

What does expression stack mean in assembly language?

I have been using a textbook to study assembly language. I am not in a class, I just want to learn assembly language. At the end of the chapter, one of the terms is "expression stack". This book tends to be very poor at clearly defining the key…
1
vote
1 answer

Evaluation of python expression

I came across the below expression in python to evaluate if a number is odd or even. While it looks elegant I was surprised to see it work. I guess for the input 3: x%2 equals 1 which evaluates to True and non-empty strings (odd) evaulate to True.…
1
vote
0 answers

In which order JavaScript executes sub expressions of an expression?

Before I had an idea that inner most groups(regardless of explicit or implicit) in an expression executed first. But as I tested the following code, I've found that I was wrong: function e(returnValue, name) { console.log(name); return…
1
vote
1 answer

What does Python consider as True or False for each primitive Type?

def toBeOrNotToBe(x, y): return x or y print(toBeOrNotToBe(0,1)) print(toBeOrNotToBe([],[1,2,3])) print(toBeOrNotToBe('','something')) print(toBeOrNotToBe(None, lambda _: None)) 1 [1, 2, 3] something at…
user12546101
1
vote
1 answer

How to evaluate a DataColumn expression faster?

I created a class that's responsible to evaluate an expression values for the row when I need it but the problem that when my methods works very slow in big datatables. public static class RowExpressionEvaluator { public static object…
Shehab
  • 431
  • 2
  • 10
1
vote
4 answers

Why do different C++ compilers give different results for this code?

I'm writing some C++ codes for fun and practice, to learn more about language features. I want to know more about static variables and their behaviour in recursive functions. Trying this code in g++ compiler, I'm given expected result: #include…
sorush-r
  • 10,490
  • 17
  • 89
  • 173
1
vote
1 answer

DynamicExpresso.SetFunction not working with method overload

I'm using Dynamic Expresso for expression evaluation and works like a charm. Actually setting up custom functions, but seems like there is a something wrong with a method overload. I've actually got two Round methods: First one with one…
Gonzo345
  • 1,133
  • 3
  • 20
  • 42
1
vote
1 answer

How to make "1 2 3" a valid expression in a Haskell REPL environment?

Some years ago, I came across with haskell.org and played a little bit with its REPL. One of the expressions that I tried was just a sequence of numbers, separated by spaces, like 1 2 3 and I was surprised, since it didn't generate an error, but was…
1
vote
1 answer

In Scheme, what is the returned value of `(begin)`?

I know that (begin expr1 expr2 ...) will evaluate all of the expressions and will return the last one evaluated. I found that in Chez Scheme it's allowed to use begin without expressions like so: (begin). I'm using Chez Scheme as part of my studies.…