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
2
votes
3 answers

return value of if statement in r

So, I'm brushing up on how to work with data frames in R and I came across this little bit of code from https://cloud.r-project.org/web/packages/data.table/vignettes/datatable-intro.html: input <- if (file.exists("flights14.csv")) { …
Jimbo
  • 2,886
  • 2
  • 29
  • 45
2
votes
1 answer

Differences between Java order of expression, operator precedence and associativity

I came across this question on an exam. Exam question: What is the result of the following code snippet? 3: var tiger = "Tiger"; 4: var lion = "Lion"; 5: final var statement = 250 > 338 ? lion : tiger = " is Bigger"; 6:…
Randomizer
  • 93
  • 1
  • 4
2
votes
2 answers

Expression evaluation order in Python

I'd like this question answered just for curiosity's sake. In the following mathematical expression (and ones like it): (( (3 * 7) + 5 * ((3 - 7) + (3 * 4))) + 9) Does Python evaluate (3 - 7) or (3 * 4) first? The thing about this is, these…
2
votes
3 answers

Has c++ standard specified the evaluation order of an operator&&(built-in)?

I always dare NOT to code like this: void func( some_struct* ptr ) { if ( ptr != nullptr && ptr->errorno == 0 ) do something... }; instead I always do like this: void func( some_struct* ptr ) { if ( ptr != nullptr ) if (…
Leon
  • 1,489
  • 1
  • 12
  • 31
2
votes
1 answer

R: How to go from a vector of strings to a vector of quotes / names?

How to get from input = c("a", "b", "c") to output = c(quote(a), quote(b), quote(c)) automatically?
Remi.b
  • 17,389
  • 28
  • 87
  • 168
2
votes
2 answers

Evaluating variable contain mathematical expression in f-strings

I have to accept input (using raw_input()) as a power expression like 10**5 and then print its value. I have tried a few pieces of code but these do not give desired results: print(f'{2**4}') #<-- prints 16 correctly a =…
Ulysses
  • 5,616
  • 7
  • 48
  • 84
2
votes
4 answers

evaluate boolean expression in java generate at runtime

How to evaluate complex boolean expressions generated at runtime in a Java program? Example: (x and y or z) and s with x, y, z boolean variables ... Thanks
2
votes
3 answers

Proper way to evaluate code

So I'm building a small app where you can evaluate some pieces of JavaScript code, but I'm having a huge "moral" problem: Initially I wanted to use eval, but I found out about its dangers, so I quickly looked for an alternative. The closest thing I…
Corrado
  • 645
  • 1
  • 6
  • 16
2
votes
2 answers

Fast boolean expression evaluator

I have an app that includes a 3 operator (& | !) boolean expression evaluator, with variables and constants. Generally the expressions aren't too long (perhaps 50 terms at the most, but usually a lot less). There can be very many expressions - I'm…
Paul Floyd
  • 5,530
  • 5
  • 29
  • 43
2
votes
1 answer

C++ constexpr expression evaluation

I have a question regarding following comment about conditional expressions used in constexpr functions: A branch of a conditional expression that is not taken in a constexpr function is not evaluated. Source: conditional evaluation of…
2
votes
1 answer

JavaScript Ambiguity between (1) and 1

What is difference between (1) and 1. 1.toString() //Will throw error 1.toFixed(1) //Will throw error (1).toString() // output "1" (1).toFixed(1) // output 1.0
Jagajit Prusty
  • 2,070
  • 2
  • 21
  • 39
2
votes
1 answer

point evaluation of NURBS curve given an axial coordinate

my question is how to get the second coordinate (in 2D) of a point that lies on a curve defined as a NURBS curve given the axial coordinate. I have the knot vector, control points, their weights and basis functions. I looked through similar…
2
votes
1 answer

How to add a new function to Ncalc

I'm using Ncalc in my new project and it already has almost everything I need . I said almost everything, because now I need to expand some functions and also add new ones such as : nth root,random, etc Do you know if anyone has already implemented…
eddy
  • 4,373
  • 16
  • 60
  • 94
2
votes
1 answer

Unity3d: Execute arbitrary javascript from C# object

I would like to string expression = "2+2"; public string evaluateExpresion(expression) { return executeJavascript(expression); // Magic javascript executor } Debug.Log(evaluateExpression(expression); How can I accomplish this?
1
vote
1 answer

eval command function within ksh script is globbing when I don't want it to

Consider the following ksh script "myquery.ksh" #/usr/bin/env ksh -eu PROCESS_TYP=$1 PROCESS_DT=$2 #Generate a query makeSQL() { local numfiles=0 local query='SEL \\* FROM TABLE_1_' case "$1" in 'ABC') query="${query}ABC" ; numfiles=1 ;; 'DEF')…