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
1642
votes
14 answers

What are rvalues, lvalues, xvalues, glvalues, and prvalues?

In C++03, an expression is either an rvalue or an lvalue. In C++11, the two value categories have become five: rvalue lvalue xvalue glvalue prvalue What are these new categories of expressions, and why are they needed? How do these new categories…
James McNellis
  • 348,265
  • 75
  • 913
  • 977
472
votes
21 answers

Expression Versus Statement

I'm asking with regards to c#, but I assume its the same in most other languages. Does anyone have a good definition of expressions and statements and what the differences are?
user1684
441
votes
17 answers

What is the difference between an expression and a statement in Python?

In Python, what is the difference between expressions and statements?
wassimans
  • 8,382
  • 10
  • 47
  • 58
317
votes
10 answers

Combining two expressions (Expression>)

I have two expressions of type Expression> and I want to take to OR, AND or NOT of these and get a new expression of the same type Expression> expr1; Expression> expr2; ... //how to do this (the code below…
BjartN
  • 5,327
  • 6
  • 28
  • 32
305
votes
4 answers

What is this smiley-with-beard expression: "<:]{%>"?

I came across the following program, which compiles without errors or even warnings: int main(){ <:]{%>; // smile! } Live example. What does the program do, and what is that smiley-expression?
Xeo
  • 129,499
  • 52
  • 291
  • 397
283
votes
3 answers

How to make Regular expression into non-greedy?

I'm using jQuery. I have a string with a block of special characters (begin and end). I want get the text from that special characters block. I used a regular expression object for in-string finding. But how can I tell jQuery to find multiple…
Rueta
  • 3,317
  • 2
  • 23
  • 22
209
votes
6 answers

XPath find if node exists

Using a XPath query how do you find if a node (tag) exists at all? For example if I needed to make sure a website page has the correct basic structure like /html/body and /html/head/title.
EddyR
  • 6,891
  • 7
  • 42
  • 50
192
votes
11 answers

How to split a long regular expression into multiple lines in JavaScript?

I have a very long regular expression, which I wish to split into multiple lines in my JavaScript code to keep each line length 80 characters according to JSLint rules. It's just better for reading, I think. Here's pattern sample: var pattern =…
Nik Sumeiko
  • 8,263
  • 8
  • 50
  • 53
185
votes
5 answers

Are complex expressions possible in ng-hide / ng-show?

I want to do so: ng-hide="!globals.isAdmin && mapping.is_default" but the expression evaluates always to false. I do not want to define special function on $scope.
Paul
  • 25,812
  • 38
  • 124
  • 247
178
votes
9 answers

How do I remove all non-ASCII characters with regex and Notepad++?

I searched a lot, but nowhere is it written how to remove non-ASCII characters from Notepad++. I need to know what command to write in find and replace (with picture it would be great). If I want to make a white-list and bookmark all the ASCII…
Texh
  • 1,823
  • 2
  • 12
  • 8
175
votes
7 answers

What does i = (i, ++i, 1) + 1; do?

After reading this answer about undefined behavior and sequence points, I wrote a small program: #include int main(void) { int i = 5; i = (i, ++i, 1) + 1; printf("%d\n", i); return 0; } The output is 2. Oh God, I didn't see the…
gsamaras
  • 71,951
  • 46
  • 188
  • 305
170
votes
3 answers

Why was the statement (j++); forbidden?

The following code is wrong (see it on ideone): public class Test { public static void Main() { int j = 5; (j++); // if we remove the "(" and ")" then this compiles fine. } } error CS0201: Only assignment, call,…
user10607
  • 3,011
  • 4
  • 24
  • 31
147
votes
13 answers

Assignment inside lambda expression in Python

I have a list of objects and I want to remove all objects that are empty except for one, using filter and a lambda expression. For example if the input is: [Object(name=""), Object(name="fake_name"), Object(name="")] ...then the output should…
Cat
  • 7,042
  • 8
  • 34
  • 36
142
votes
9 answers

converting a .net Func to a .net Expression>

Going from a lambda to an Expression is easy using a method call... public void GimmeExpression(Expression> expression) { ((MemberExpression)expression.Body).Member.Name; // "DoStuff" } public void SomewhereElse() { …
Dave Cameron
  • 2,110
  • 2
  • 19
  • 23
131
votes
8 answers

C# Float expression: strange behavior when casting the result float to int

I have the following simple code : int speed1 = (int)(6.2f * 10); float tmp = 6.2f * 10; int speed2 = (int)tmp; speed1 and speed2 should have the same value, but in fact, I have : speed1 = 61 speed2 = 62 I know I should probably use Math.Round…
Baalrukh
  • 1,330
  • 2
  • 9
  • 11
1
2 3
99 100