Questions tagged [expression]

Combination of several programming symbols and values intending to produce a result

An expression is code before it gets evaluated. That is, evaluating an expression will give you a result.

Expressions can consists of combinations of variables, constants, operators, function calls, or whatever constructs are available in that language.

Many s have an expression data type, and an evaluation function (often called eval), where calling eval(an_expression) will calculate a result.

Related tags

7598 questions
2
votes
2 answers

How can I replace tokens in string?

I have a json object const item = { fooUrl : 'www.google.com', fooDomain : 'www.yahoo.com' } and an input string foo$ENV[fooDomain]bar. I want to replace the $ENV[fooDomain] with item.fooDomain and similarly for accountsUrl, I want this to…
dota2pro
  • 7,220
  • 7
  • 44
  • 79
2
votes
0 answers

Why triggers this noexcept operator an "overloads have similar conversions" error for MSVC but not for Clang and GCC

I have the following code struct S { template operator T() const noexcept (noexcept(static_cast(1) - 1)) // comment out this line to make it work in MSVC { return static_cast(1) - 1; } }; struct R { …
jesses
  • 559
  • 3
  • 15
2
votes
1 answer

Output Expression Value constant-like

I have to send expressions over http to my backend. This backend knows about enum Fun but doesn't have a reference to funs. My job is to serialize exp2 in a way the backend can still deserialize it Is there a way to force passing the enum value…
Csharpest
  • 1,258
  • 14
  • 32
2
votes
1 answer

JSP error escape quotes in expression

I need to check type to display correct message like: ${row.type} Important Note But the problem that escaping produce strange error: Unable to analyze EL expression due to lexical analysis error How…
Lorenzo Manucci
  • 850
  • 2
  • 14
  • 28
2
votes
1 answer

Is there a way to implement this using C++17 Fold Expressions?

Imagine I have this template class. template class message_handler_set { public: static bool call_handler(const MessageType& command) { // Call each TMessageHandler type's 'call_handler' and return the…
JWellbelove
  • 121
  • 2
  • 6
2
votes
1 answer

Evaluated Bash expression within npm install command

I want to install a list of packages from a simple text file (yes, package.json is what this was designed for) my first approach was this: npm i $(cat builder-dev-packages.txt) -g similar to this: docker rm $(docker ps -a -f status=exited -q) But…
Nate W
  • 25
  • 1
  • 6
2
votes
7 answers

Lambda expression with and System.Nullable

This can't compile: void Foo() { using (var db = new BarDataContext(ConnectionString)) { // baz is type 'bool' // bazNullable is type 'System.Nullable' var list = db.Bars.Where(p => p.baz && p.bazNullable); //…
radbyx
  • 9,352
  • 21
  • 84
  • 127
2
votes
1 answer

looping through a string and checking if certain conditions are met

I need to write a piece of code which accepts an input string parameter and determine if exactly 3 question marks exist between every pair of numbers that add up to 10. If so, return true, otherwise return false.Some examples test cases are…
maryam bg
  • 23
  • 4
2
votes
2 answers

Use a saved expression inside another expression

Is it possible to do something like this: public static Expression> IsAGood = x => x.A != null && x.A.valid; public static Expression> IsBGood= x => IsAGood…
sgch
  • 77
  • 1
  • 7
2
votes
3 answers

PHP regular expression allowing at most 1 '.' or '_' character in string, and '.' or '_' can't be at beginning or end of string

I am writing a PHP validation for a user registration form. I have a function set up to validate a username which uses perl-compatible regular expressions. How can I edit it so that one of the requirements of the regular expression are AT MOST a…
skcin7
  • 783
  • 1
  • 10
  • 24
2
votes
1 answer

How to manipulate pixel values via image expression?

Recently I am writing a script to manipulate the pixel values in an image. The idea is to set the pixels that fall into the given range to a specific value. Instead of using the command "for" which loops from pixel to pixel, an image expression was…
2
votes
1 answer

PHP: Regex preg_replace_callback to match all numbers in PHP

preg_replace_callback( "/[0-9]*/", array( &$this, '_getPHPNumber' ), $code ); private function _getPHPNumber( $matches ) { return ( $this->_getHtmlCode( $matches[0], PHP::$Colors['number'] ) ); } private function _getHtmlCode( $text, $color )…
Nahydrin
  • 13,197
  • 12
  • 59
  • 101
2
votes
1 answer

Does an algorithm for extracting sub expressions from an expression exist?

Suppose I had the expression: v = ((((x * 3) * y) * 5) * z) + 5 And I want to reduce the amount of operations as much as possible in v by moving sub expressions into different variables, yet maintaining that y must only occur in v, such as: a = x *…
2
votes
4 answers

The result of "sizeof" depends on the location of the brackets. Why?

There is a code: float x=-8.92; int y=5; printf("%u\n", sizeof x+y); printf("%u\n", sizeof (x+y)); Conclusion: 9 4 Why is this happening(result 9)? After all, these are simple unary operations.
2
votes
1 answer

C# Visitor pattern Expressions to build result Unit of measure

I am embarking on a project involving some calculations and have started with a fairly straightforward UOM (Unit of Measurement) adaptation based on the Cureos framework. So far so good, I've got some basic Units represented. One of the things I…
Michael
  • 57
  • 1
  • 7
1 2 3
99
100