FAQ Database Discussion Community


How to remove Parantheses from System.Linq.Expressions.Expression?

c#,linq,lambda,expression,expression-trees
Suppose the following class defined: public class Person { public int Age { get; set; } } Now I want to build an Expression which compares the Age property to be Greather than 20, like this: ParameterExpression param = Expression.Parameter(typeof(Person), "Person"); MemberExpression member = Expression.Property(param, "Age"); ConstantExpression constant = Expression.Constant(20);...

Using Expression to Hide Certain Data in SSRS

ssrs-2008,expression
I'm trying to hide/suppress data using an expression for Row Visibility in SSRS. I currently have an expression: =IIF(CInt(Fields!EM_ET.Value)=1 Or CInt(Fields!EM_ET.Value)= 2,True,False) That hides certain data I do not want to appear, but I would like to add an additional field to hide as well. I tried adding an additional...

Dividing an Expression in C# using Expression.AndAlso() causes an Exception

c#,linq,lambda,expression
On my project written in C#, I've found a HUGE predicate that is used in this method of linq : public static IQueryable<TSource> Where<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate); this predicate works perfectly, but it as so much condition that I struggled a lot before understanding it. I would like...

IOS. Parsing and evaluating logical and math expressions

ios,parsing,expression
I'm looking for a library for parsing and evaluating logical and math expressions from String. The main features what i need: Check expression's type(logical or math ) Parsing and evaluating math expressions. Ex: "3*(2+1)" Parsing and evaluating logical expressions. Ex: "(2+1 == 0) || (5 >= 10)" Must be work...

Apply a dynamically created lambda to an object instance

c#,lambda,expression,expression-trees
I have some code which dynamically create a lambda starting from strings. For example, I have a filter class like the following: public class Criteria { public string Property { get; set; } public string Operator { get; set; } public string Value { get; set; } } And I...

Creating an Expression that returns an object

c#,.net,lambda,expression
I have this method: public R TranslateExpression<R>(Expression exp) where R : DbRequest { //... } In another class I have the following method: public void Persist(E entity) { Expression expr = Expression.Return(entity); //Does not compile, but I'm looking for something like this PersistRequest request = TranslateExpression<PersistRequest>(expr); } How can I...

Lambda expression alternative to several if statements

c#,lambda,expression,predicate
I'm trying to accomplish an expression function alternative private static Expression<Func<UserProfile, bool>> CompareFilter(FilterViewModel f) { ... } on this one: private static bool CompareFilter(UserProfile profile, FilterViewModel filter) { if (filter.FirstName != null) { if (profile.FirstName != null) { if (profile.FirstName.CompareTo(filter.FirstName) != 0) { return false; } } else { return...

call Equal method of Expression

c#,lambda,expression
when I run this code Expression left = Expression.Constant(10, typeof(int)); Expression right = Expression.Constant(10,typeof(int)); var method10 = typeof(Expression).GetMethod("Equal", new[] { typeof(Expression), typeof(Expression) }); Expression exp = Expression.Call(method10,left,right); var lambda = Expression.Lambda<Func<bool>>(exp); var compiled = lambda.Compile().DynamicInvoke(); I get the below error Additional information: Expression of type 'System.Int32' cannot be used for...

Regular Expression how to find last folder in a path

regex,path,expression
I would like to find the last folder in a path. Ex: G:\DATA1\DATA2\DATA3\DATA4\my target\file.xxx I need to extract my target I try with (^.*\\)(.*\\) but the result is my target\ someone can fix it. Thanks...

ANTLR: expression evaluation with custom object and method

expression,antlr
Is it possible to use ANTLR internally in a Java program and use custom classes to execute actual operations ? I would like to be able to parse simple expressions and execute custom operations for them defined in my own Java classes. Sample expression : (( AB1 op1 BC2) op2...

R data.table: reuse an aggregation

r,expression,data.table,aggregate,quoting
I want to apply the same aggregation to multiple data tables, without rewriting the aggregation scheme. Consider dt1 <- data.table(id = c(1,2), a = rnorm(10), b = rnorm(10), c = rnorm(10)) dt2 <- data.table(id = c(1,2), a = rnorm(10), b = rnorm(10), c = rnorm(10)) dt1_aggregates <- dt1[, .(mean_a=mean(a), sd_a=sd(a),...

Ruby REPL, determinate if a line it's part of a valid expression

ruby,expression,read-eval-print-loop,lexical-analysis
I'm doing a Ruby REPL (just a hobby, won't be big and professional like pry). I wrote a very simple REPL that works fine if the input it's just a single valid line of Ruby: loop do print "ruby> " input = gets puts "=> #{eval(input)}" end I want to...

Greek letters in legend in R

r,expression,legend
I want to have three curves on the same plot with different parameter alpha. curve(sin(x), from = 1, to = 3, lty = 1, ylim = c(-1, 1)) curve(sin(2 * x), add = TRUE, lty = 2) curve(sin(3 * x), add = TRUE, lty = 3) legend("topright", legend = expression(paste(alpha,...

Negating an Expression

c#,linq,expression
I have a function that returns an expression, I pass in a field and a value. I have the function returning StartsWith, but I want to return NOT StartsWith private Expression<Func<T, bool>> GenerateFieldDoesNotStartsWithExpression<T>(string fieldName, string value) { var parameter = Expression.Parameter(typeof(T), "i"); var fieldAccess = Expression.PropertyOrField(parameter, fieldName); MethodInfo method =...

DropDownListFor method to take another parameter

c#,asp.net,asp.net-mvc,generics,expression
In here i bind Dropdown list using Enum.(bind is successful).But i wanted to add css class to it,But in here it need to add, "DropDownListFor "<"TModel,TProperty">" method to take another parameter for css class name." My Dropdownlist @Html.DropDownListFor(m => m.ReportType) But i need belowone to accept in MyDropdownlist method, @Html.DropDownListFor(m...

Why is my LINQ Expression with multiple parameters not compiling?

c#,linq,parameters,expression
I want to extend the LINQ expression (DoSomething) using LinqKit; // for System.Linq.Expressions.Expression<>.Invoke() public class Expressions { public static System.Linq.Expressions.Expression< System.Func<int, int, int, int, bool>> DoSomething = (a, b, c, d) => false; } public class ExpressionTester { public ExpressionTester() { Expressions.DoSomething.Invoke(1, 2, 3, 4); } } with an additional...

Use LINQ select as method parameter in C#

c#,linq,lambda,expression
I am trying to create a generic method for HTML table building. As part of the functionality I need, I'd like the user to be able to specify the properties that will be turned into columns. As this is a generic method, I had thought that the user could pass...

MethodCallExpression is not setting up the orderby correctly

c#,linq,expression
I'm new to this expression business. I am modeling after this example: https://msdn.microsoft.com/en-us/library/vstudio/bb882637(v=vs.110).aspx I am trying to get a list of my offices that satisfies a specific name. The code works up to the point that I need to setup the order by. I keep getting this error: ParameterExpression of...

AngularJS no expression replacement with dynamic data in scope?

javascript,angularjs,controller,scope,expression
first of all: AngularJS beginner over here so maybe this question is the simplest ever or I have just not enough knowledge yet (though I don't figure out what to google for ;) ) I have just started to use Angular.js and tried to compute the date difference between two...

C# Expressions - FatalExecutionEngineError

c#,debugging,visual-studio-2013,expression,expression-trees
Today I was debugging some code of mine that builds a few ExpressionTrees, compiles them to callable Delegates and calls them afterwards if required. While doing this I encountered a FatalExecutionEngineError stepping through the code: At first I was a little bit shocked since I had no idea what could...

Fastest way to memoize expression

c#,.net,expression,expression-trees,memoization
I have a function, that transform input Expression to output BlockExpression. So I write this code: private static readonly Dictionary<Expression, BlockExpression> MemberMemoizeDictionary = new Dictionary<Expression, BlockExpression>(); private static BlockExpression CreateBody<TProperty>(CustomComparer<T> comparer, Expression<Func<T, TProperty>> member, bool createLabel) where TProperty : IComparable<TProperty>, IComparable { BlockExpression expression; if...

How to assign values for a list of some objects defined as variable with Spring Expression Language(Or the other expression languages you aware of)

java,spring,expression,el,spring-el
In Spel, it is easy to assign some values for a List property. For example having object foo with a property defined as List, I usually do: SpelParserConfiguration config = new SpelParserConfiguration(true,true); ExpressionParser parser = new SpelExpressionParser(config); Foo foo = new Foo(); EvaluationContext context = new StandardEvaluationContext(foo); parser.parseExpression("barList[1].test='11111111'") .getValue(context); But...

How to access OrderBy clause from MethodCallExpression

c#,linq,expression,expression-trees
I have a custom LINQ provider that processes a MethodCallExpression that has a OrderBy clause inside it. How can I get hold of the OrderBy clause so that I may process it?

Trying to SORT table on Expression

sorting,reporting-services,ssrs-2008,expression
I have two tables in my report. Grouped on fields DatePaidFinancialYear and then SupplierName. I have removed both sorts on the groups themselves. There is also no sort on the tablix. I then have a COUNT IF in one table that does the following - =Count(IIF(Fields!DaysLateCategory.Value = "Over10Days" , 1,...

How can one store a binary operator in a variable?

r,foreach,expression
I am pretty confused about the meaning of the %Something% operators. How can one store a binary operator in a variable? Something like... binary_operator = store.binary(%in%) c(3,9,4,1,7) binary_operator c(1:5) # would behave alike "c(3,9,4,1,7) %in% c(1:5)" or something like library(foreach) binary_operator = expression(%do%) # or expression(%dopar%) ... ... foreach (i=1:6)...

How to pass an expression “from higher level” to mutate?

r,expression
I would like to create a higher level function that wrap a mutate. I want to give an expression parameter to my function and being able to use this expression in mutate : datas <- data.frame(x = sample(100)) fn <- function(datas, expr) { mutate(datas, flag = eval(substitute(expr), datas)) } fn(datas[1],...

NSExpression custom variables inside expression

ios,objective-c,swift,expression
Recently I have discovered NSExpression class and I am wondering is there a possibility to evaluate custom variables inside expression. Something like this: 5+4+MYVAR*5 I would like to replace this MYVAR string with custom Double value. If this don't exists, I will go with loops and similar, but hoping that...

Evaluating an expression which contains an expression

angularjs,expression
I am a newbie to Angular js and I just started doing a project in Angular JS. Let me give you a brief idea about my application. I have a json data which contains data of some nodes, which form a hierarchy. I am using to display this data. So...

Shorthand expression for an if ( $a == $b || $a == $c ) statement

php,regex,if-statement,operators,expression
I know this code will work: echo ( $a == $b || $a == $c ) ? "Yes" : "No"; That can be read like: if $a is equal to $b or $a is equal to $c Is there a way to make it more shorter like: if $a is...

How to convert from Expression to CriteriaBuilder in JPA

java,spring,jpa,expression,criteria
I have below code which uses outdated Expression Criteria criteria = getSession().createCriteria(TagSynonym.class); criteria.add(Expression.like("title", "%"+piece+"%") ); criteria.setFirstResult(0); criteria.setMaxResults(maxTagsInResult); return criteria.list(); I want to achieve same with CriteriaBuilder. Below is what I tried, however it returns an empty array. Please guide what do I miss here. Also guide how to set limit...

SSRS. How to hide blank/empty column via expression?

reporting-services,ssrs-2008,expression,ssrs-2012
I need to hide column if all rows in column is empty (blank). In this case col3 should be hidden, because no values in column. col1 col2 col3 v1 v4 v2 v3 I'm using following expression on columns Hidden property: =IIF(Fields!Test5.Value = "",TRUE,FALSE) This expression working, but It hidding each...

Expression that factors S into Y so X evaluates to either Y or -Y?

javascript,math,expression
How do I write an expression that factors s (either 0 or 1) into y (any value) so x evaluates to either y or -y? e.g. y is 180 if s is 0, x should be 180 if s is 1, x should be -180...

Incorrectly calculated sum expressionForKeyPath sum: core data

objective-c,math,core-data,expression
May be I'm doing something wrong? So, I have few Entities with relationship "Shop->amountIncome and -> amountExpense" And I'm trying to count total income and expense. I have dynamic tabelView I start with - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { and some search Shop *shop = nil; if (self.searchPredicate ==...

Regular Expression does not accept correct inputs

java,regex,error-handling,expression,user-input
I am developing a Java method, which checks, if the user input is valid. For that I wrote four regular expressions to check that. The first three work fine. The last one, the "most complex" regular expression, does not accept values, which should be accepted. I want to make sure,...

Issue with Expression in For Loop - Bash

bash,for-loop,expression,eval
I am trying to loop through a list of servers and rather than manually enter each one in a text file, I wanted to use an expression. Example: [[email protected] ~]$ for i in server{001..010} ; do echo $i ; done server001 server002 server003 server004 server005 server006 server007 server008 server009 server010...

Expression> VS Func

c#,linq,expression
I've just come across Expression trees and I found that its is better to use them with LINQ than just Func<T, Boolean>. However, I found that I can't directly pass an Expression to a LINQ method, let's say the Select method. But I found that there is a Compile method...

Background Color Not Filling in Entire Row Based off Expression in SSRS

ssrs-2008,expression,visibility
I was hoping I could get some help on this issue. Got a report that displays data for events; of which we have two types: fixed and mobile. To fill in the row based off what type the event is, I used this expression: =IIF(Fields!OwnerType.Value = "Fixed", "LightSteelBlue", "#FFFFFF") But...

Is there any way of breaking up an Expression> and get the right hand side of the equality comparison?

c#,linq,lambda,expression,equality
This may be a longshot, but I will try it anyway. Let's say that I have an expression in these manners: public class Foo { public int Id { get; set; } } Expression<Func<Foo, bool>> expr = p => p.Id == 2; Is there any way of breaking up the...

PCRE pattern that validates more than I wants

regex,expression,pcre
In order to develop a routing module for a Web app, I have to make intensive use of regular expressions. I have to test URIs of the form: /Services/service_name/List/of/Parameters/or/nothing The service name is mandatory, but not the end of the line parameters. The line can either end with a slash...

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

c,expression,compiler-warnings,comma-operator
After reading this answer about Undefined behavior and sequence points, I wrote a small program: #include <stdio.h> int main(void) { int i = 5; i = (i, ++i, 1) + 1; printf("%d\n", i); return 0; } and the output is 2. Oh God, I didn't see the decrementation comming! Can...

F# record list expressions

list,f#,expression,record
Hello my question is about list expressions in F#. I try to create a record that will be stored in a list. I want the Point record inside the Square record to update from 1-9. To clear out what I mean it's like when you write let example = [1...

What is the mysterious secret whitespace character?

c#,regex,string,expression
I've got an issue with regex. I've got code right now that replaces tabs (\t), newlines (\n), and any alphabetic or numeric character followed by a carriage return (([a-z,A-Z,0-9])\r) with blanks. They work great! Problem is, it's missing a specific newline character that I can't see, even with the symbols...

Write own assert Function with expressions

c#,lambda,expression
I would like to create my own Assert method similar to the code below, but it is not working. // Method Usage Argument.Assert(() => Measurements.Count > 0); // Method Implementation public static void Assert(Expression<bool> expression) { bool value = expression.Compile(); if(!value) { throw new InvalidOperationException("Assert: " + expression.ToString() + "...

ng-class expression: merge condition and class name

javascript,angularjs,expression,directive,ng-class
Supposing I have 3 variables (they can change its value): $scope.A = 'one'; $scope.B = true; $scope.C = false; <div ng-class="A"></div> renders <div class="one"> <div ng-class="{'two': B, 'three': C}"></div> renders <div class="two"> How can I merge a variable and a expression to render <div class="one two">? Do I have to...

C++ execution order when passing function arguments [duplicate]

c++,function,expression,iso
This question already has an answer here: Order of evaluation in C++ function parameters 3 answers A container class with the following interface: template <typename T> class DynArray { /// Returns the number of elements in the array. inline size_t GetCount(); /// Releases the internal memory from the \class...

Why isn't a final variable always a constant expression?

java,expression,constants,compile-time-constant,narrowing
In the below code: final int a; a=2; byte b=a; // error: possible loss of precision Why do I get this error? Isn't a final variable compile time constant expression and hence implicitly narrowed to byte during the assignment? In other words isn't the above code equivalent to: final int...

Delete all expressions in Expression editor

python,expression,maya
In this maya scene file of mine, when scrubbing through the time slider, I keep getting the following error: // Error: An execution error occured in the expression stabilizator_expression_mom_bq01_v2_original_2Shape6. // Upon opening the editor, this is the full error: # Error: line 0: No module named mmTools.v1_0.ford_stabilizerStereo # Traceback (most...

Write Live expressions in after effects cc using Extendscript?

scripting,expression,extendscript,after-effects
I am trying to write a script for after effects CC using Extendscript. I wonder if it is possible to add live expressions to a layers properties like thisComp.layer("Layer 1").transform.position and so on. Hoping it is possible. Thanks in advance :)...

Dynamically create expression for ggplot legend?

r,ggplot2,expression,legend
I want to plot a line graph, with multiple lines, coloured depending on a grouping variable. Now I want to set the legend labels via scale-command: scale_color_manual(values = colors_values, labels = ...) The legend labels are as following: "x^2", "x^3", "x^4" etc., where the range is dynamically created. I would...

variable '' of type '' referenced from scope '', but it is not defined

c#,lambda,expression
Well, the following code is self-explaining; I want to combine two expressions into one using And operator. The last line causes rune-time the error: Additional information: variable 'y' of type 'System.String' referenced from scope '', but it is not defined Expression<Func<string, bool>> e1 = y => y.Length < 100; Expression<Func<string,...

How to parse through a table to gather tide value at a certain time of day

javascript,expression
I have been having some quiet days at work and schools out but I wanted to play around with javascript. I'm trying to figure out regular expressions and such. I may be starting out too complicated, I am not too sure. How hard is it to parse through a table...

Dynamic Lambda Expression call

c#,linq,generics,expression
I'm getting this exception when I run this code. ParameterExpression of type System.Int64 cannot be used for delegate parameter of type System.Object I know it's something to do with the Expression.Lambda<func<object,bool>> part of the code. Overall, I want to pass any type of ParameterExpression into this method and it will...

AngularJS Filter by Inline Expression

javascript,angularjs,expression,angularjs-filter
I'm trying to add an inline Angular filter that filters via an expression that evaluates to true or false. Here's my JS: angular.module('programApp', [ 'programApp.controllers', ]); angular.module('programApp.controllers', []) .controller('programController', ['$scope', '$filter', function($scope, $filter){ $scope.advancedFilters = 1; $scope.bars = [ {'name':'First', 'id':1}, {'name':'Second', 'id':2}, {'name':'Third', 'id':3}, {'name':'Fourth', 'id':4}, {'name':'Fifth', 'id':5}]; }]);...

AWS DynamoDB Scan filterExpression - simple number comparison

amazon-web-services,expression,amazon-dynamodb
I am trying to do a simple dynamoDB scan with a filter expression (documentation here) This is my expression string: "attribute_exists("my_db_key") AND ("my_db_key" = 1)" This simply states: "If a value for my_db_key exists AND my_db_key EQUALS 1, return it in the results" However it does not work and I...

Finding the Number of Times an Expression Occurs in a String Continuously and Non Continuously

java,regex,string,algorithm,expression
I had a coding interview over the phone and was asked this question: Given a String (for example): "aksdbaalaskdhfbblajdfhacccc aoudgalsaa bblisdfhcccc" and an expression (for example): "a+b+c-" where: +: means the char before it is repeated 2 times -: means the char before it is repeated 4 times Find the...

R: sequence of substituted expressions from sequence of values

r,expression,quote
I want to produce list(quote(10^2), quote(10^3), quote(10^4), quote(10^5), quote(10^6), quote(10^7)) from seq(2,7) is there a less gawdawful way to do that than mapply(function(n) substitute(10^x, list(x=as.double(n))), seq(2,7)) ? I have tried the following: > substitute(10^x, list(x=seq(2,7))) 10^2:7 > mapply(substitute, 10^x, x=seq(2,7)) Error in mapply(substitute, 10^x, x = seq(2, 7)) : object...

Terminology: what is the precise definition of “type expression” in Haskell, as used in Thompson's book?

haskell,types,expression,terminology
What is the precise definition of the term "type expression" as used in Thompson's "Haskell - the craft of functional programming" book ? It seems that this term is not defined in the book. It is for example not listed in the index. Also, I tried to search for a...

Pass LINQ query to method to slect dynamically form collection

c#,linq,expression,func
I already looked up on the question on SO, but couldn't find a solution for my problem. In my program is a class whose sole reason is selecting from a collection of data passed to it via constructor. What I need to to is pass a LINQ query to the...

Can comma separated expressions be used as if statement in Javascript?

javascript,expression,comma
I'm trying to make sense of script which is makeing heavy use of comma-separated expressions. For example: popup_window != is_null && ("function" == typeof popup_window.close && popup_window.close(), popup_window = is_null); If it's true that comma separation means "evaluate all of the following expressions, then produce the value of the final...

What optimization technique does ghci use to speed up recursive map?

haskell,optimization,expression
Say I have the following function: minc = map (+1) natural = 1:minc natural It seems like it unfolds like this: 1:minc(1:minc(1:minc(1:minc(1:minc(1:minc(1:minc(1:minc(1:minc(1:minc... 1:2:minc(minc(1:minc(1:minc(1:minc(1:minc(1:minc(1:minc(1:minc(1:minc... 1:2:minc(2:minc(2:minc(2:minc(2:minc(2:minc(2:minc(2:minc(2:minc(minc... 1:2:3:minc(3:minc(3:minc(3:minc(3:minc(3:minc(3:minc(3:minc(minc(minc... ... Although it's lazily evaluated, to build each new number n in the list is has to unfold an expression n times which gives us...

Simplify Boolean statements (Java)

java,boolean,expression
I am trying to simplify the following boolean expressions. However, I can't figure them out. I would like to know how to get to the answer. Where b is a boolean andnis anint` A. if (n==0) {b=true;} else {b=false;} // is it b=!n; ???? B. if (n==0) {b=false;} else {b=true;}...

Expression.Call, Int32 and Enum

c#,fluent-nhibernate,expression,kendo-grid
Can't figure out how to build an expression that compares an enum type with an int. I have a MVC site with Kendo components embedded. In the view-class, the property is an ENUM, but the view returns an Int32 (the source is a Kendo IFilterDescriptor). So the problem is...: I...

Expression tree data structure

c++,class,tree,expression
I want to implement a simple arithmetic expression tree data structure in c++, such that an expression tree object is initialised by: ExprTree(operator, expression1, expression2). Here is an example of how it should work: double x = 1, y = 2, z = 0.5; expr1 = ExprTree('*', x, y); //...

Replace part of BlockExpression

c#,.net,expression,expression-trees
Here is a BlockExpression var compareTo = GetCompareToExpression<TProperty>(expression, parameters); var compareToVariable = compareTo.Key; var compareToCall = compareTo.Value; var zero = Expression.Constant(0, typeof (int)); LabelTarget ret = Expression.Label(typeof (int)); var block = Expression.Block(new[] {compareToVariable}, Expression.Assign(compareToVariable, compareToCall), Expression.IfThen(Expression.NotEqual(compareToVariable, zero), Expression.Return(ret, compareToVariable)), Expression.Label(ret, zero)); return block;...

Parse a string expression

python,regex,parsing,expression,eval
I need to parse a string which contains an expression. The language is proprietary and I am not sure I know the complete syntax but essentially an example expression looks like this: "some_name+(some_other_name * 4 * different_name)+ 'h40028" There are various names i've illustrated as some_name etc above which I...

F#: type matching on DU cases, make this slightly more generic

f#,expression,discriminated-union
In this previous question, there is a lovely solution to asking if an object is a particular union case: let isUnionCase (c : Expr<_ -> 'T>) = match c with | Lambdas (_, NewUnionCase(uci, _)) -> let tagReader = Microsoft.FSharp.Reflection.FSharpValue.PreComputeUnionTagReader(uci.DeclaringType) fun (v : 'T) -> (tagReader v) = uci.Tag |...

ANTLR4 Exrpression evaluator error

java,expression,antlr,evaluator
I wanted to try this sample code out but i cannot get it to run because i am having compiling errors. I also added an image of my eclipse. which whos where the errors are. Here is the Grammar: grammar Expr; eval : expr EOF ; expr : expr '*'...

Leading Zero with Datestamp in SSIS Expression

sql-server,ssis,expression,substring
I'm trying to format a datestamp to have leading zeros in an expression using SSIS 2008 R2. My desired result would be Exceptions - YYYYMMDDHHMMSS.xls so as an example, now would be: \\SomePath\Exceptions - 20150211155745.xls I am having an issue adding the leading zeros to the day and month though....

I have and expression like “ABC or DEF and ( GHI or JKL)” . Now I want to extract all the operands from this expression

jquery,regex,expression,string-matching,string-parsing
ABC or DEF and ( GHI or JKL) Here, the operand ABC can be a phrase which may contain spaces. The only operators are and, or. Can anyone suggest a way to fetch all the operands? I thought to do it this way: There will be a list of operators...

python - calling a function from within itself

python,function,math,recursion,expression
The code I already have is for a bot that receives a mathematical expression and calculates it. Right now I have it doing multiply, divide, subtract and add. The problem though is I want to build support for parentheses and parentheses inside parentheses. For that to happen, I need to...

How to properly merge lambda-expressions with different parameters

c#,lambda,expression
I have two expressions : Expression<Func<long, bool>> condition = x => x < max; // Exp # 1 if (count > 0) { Expression<Func<int, bool>> limit = x => x > -1; // Exp # 2 condition = Expression.Lambda<Func<long, bool>>( Expression.AndAlso(condition, limit), condition.Parameters); } var comparator = condition.Compile(); while (comparator(k++,...

Time's Tables Quiz (Error)

c,if-statement,syntax-error,expression
HELP NEEDED :D So trying to embark on making a time's tables quiz for my brother.Very new to coding so trying to do it as simple as possible but really stuck. Any help would be awesome Basically I keep getting this error [ In function 'main': Line 17: error: expected...

Recursive expression in Report Builder 3

reporting-services,expression,recursive-query
I've got some data in report, grouped by year/month. Is there any way to refer to previous month data with recursive way? I need to implement such formula: Backlog = last_month_backlog + (sum_of_open – sum_of_close) where last_month_backlog is (sum_of_open – sum_of_close) from the previous month. For example Februrary: 5 open,...

Does JavaScript have the concept of l-value and r-value?

javascript,expression,ecmascript-5,referenceerror
In JavaScript, if you put some kind of expression on the left side of an assignment expression, the engine will throw a ReferenceError. For example, // 'this' on the left side this = window; // ReferenceError: Invalid left-hand side in assignment or // function call expression on the left side...

OrderBy with SwitchExpression in Linq to entities

c#,linq,linq-to-entities,expression,expression-trees
I need make custom orderby for enum. I try use SwitchExpression: public static IQueryable<T> MyOrderByEnum<T>(this IQueryable<T> source, string propName, Type enumType) { var type = typeof (T); var property = type.GetProperty(propName); var parameter = Expression.Parameter(type, "p"); var propertyAccess = Expression.Property(parameter, property); var enumValues = Enum.GetValues(enumType); var switchCases = new SwitchCase[enumValues.Length];...

Cookie Regular Expression in python

python,python-3.x,cookies,expression
Im trying to find the easiest way to convert a string containing 3 cookies into 3 seperate variables each containing one cookie. I was trying regular expression but ive tried so many different approaches I'm kinda lost now... Any suggestions on an approach that would be best? or confirmation that...

Applying DataFrame with logic expression to another DataFrame (need Pandas wizards)

python,pandas,expression,signal-processing
I have a DataFrame conditions with a set of conditions that are used like an expression: indicator logic value Discount 'ADR Premium' '<' -0.5 Premium 'ADR Premium' '>' 0.5 Now I have a dataframe indicators with a set of values, in this case there is just one indicator ADR Premium:...

Create expression for a simple math formula

c#,.net,expression,.net-4.5,expression-trees
I have some fun with Expressions and a question appears: it throws an exception that I didn't suppose. I have an input - simple math formula, for example 2*x+3, and I want to create an expression tree for it. So I write this code using System; using System.Linq.Expressions; namespace ConsoleApplication50...

Regular expression to substitute a pattern in VB script

regex,vbscript,expression
I am trying to write a regular expression in VB script to substitute some patterns. My string may contain zero or more following patterns - &USERID &amp;USERID &USERID. &amp;USERID. &USERID(n) &amp;USERID(n) &USERID(n). &amp;USERID(n). &USERID(n1, n2) &amp;USERID(n1, n2) &USERID(n1, n2). &amp;USERID(n1, n2). Sample string - C:\temp\&USERID_&amp;USERID._&USERID(4)_&USERID(2,2)..txt If USERID=ABCDEF, then once substituted...

Regular Expression differences between [] and ()

php,design-patterns,expression
How to understand about this Pattern? /^((?:\+?61)|0)(2((3[3789])|(4[0123456789])|(5[012356789])| (6[0123456789])|[789][0-9])|(3((3[234])|(4[012345789])|(5[0123456789])| (6[123457])|[789][0-9]))|(7(([23][0-9]|(4[0123456789]))|(5[234567])| (7[679])))|(8((2[56])|(5[123458])|(6[0123456789])|(7[0123456789])| (8[0123456789])|(9[0123456789]))))[0-9]{6}$/ How the square bracket[] and Parenthesis() differ from? ...

AngularJS observe directive attribute expressions, inherit scope dynamically

javascript,angularjs,angularjs-directive,angularjs-scope,expression
My code is as simple: .controller('Ctrl', ['$scope', '$timeout', function ($scope, $timeout) { $timeout(function () { $scope.x = 5; }, 2000); }]) .directive('ngHey', ['$parse', function ($parse) { return { 'restrict': 'A', 'scope': true, 'link': function($scope, el, atr) { var go = function () { if ($parse(atr.ngHey)()) { alert('oiiiiiii'); } }; atr.$observe('ngHey',...

Create Python List using a True/False expression check? [duplicate]

python,list,if-statement,expression
This question already has an answer here: Inconsistent comprehension syntax? 4 answers Looking to generate a Python list that uses an if statement to check whether a number is even or odd. If even take the List value as '1' and if odd take the list value as '0'....

Add to LINQ Include Expression

c#,linq,entity-framework,expression
I am writing a function that allows a user to get a queryable list of devices from the database (the underlying provider is EF). But I want to allow them to specify their own includes, but if they do always include the default include of Capabilites how do I do...

C assign string from argv[] to char array

c,arrays,expression,variable-assignment,argv
I have the following code which reads an file name from the command line and opens this file: #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv){ FILE *datei; char filename[255]; //filename = argv[1]; //datei=fopen(filename, "r"); datei=fopen(argv[1], "r"); if(datei != NULL) printf("File opened"); else{ printf("Fehler beim öffnen von %s\n", filename);...

Getting an R expression from a value (simlar to enquote)

r,expression
Assume I have a value x which is of some (unknown) type (especially: scalar, vector or list). I would like to get the R expression representing this value. If x == 1 then this function should simply return expression(1). For x == c(1,2)) this function should return expression(c(1,2)). The enquote...

SSRS Expression To Remove Leading 0 In Date

datetime,ssrs-2008,expression
My report displays the date time as "Friday, May 08, 2015" but I'd like to remove the 0 in the date field if the value is a single digit. Should I use an expression to handle this? And if so, could I get some help on the expression? Thanks,...

Linq Expression Building Incorrect number of parameters supplied for lambda declaration

c#,linq,lambda,expression
So I'm trying to build a Generic Expression that Takes in a Datetime property from an IQueryable, and applies a Day comparison against it. However I keep getting an Error forIncorrect number of parameters supplied. My function looks like this: public IQueryable<T> SetDateCompare<T>(IQueryable<T> OriginalQuery, Expression<Func<T, DateTime>> getDateFunc, DateTime ComparisonDate, bool...

Adobe After Effects: Keep “Expression-Relations” when duplicating multiple layers

duplicates,expression,adobe,after-effects
just wanted to ask, whether there is a way to keep the relations of expressions going when duplicating layers. E.g. I have two layers, "LayerA" and "LayerB". Now I have an expression going on in "LayerB" saying, that its position always equals the position of "LayerA". Now when I duplicate...

Is println! an expression or a statement?

expression,rust
I'm working through the Rust documentation (book) and am confused about it's use of semicolons to separate statements. In one example it uses the println! macro as a statement terminated by a semicolon: use std::cmp::Ordering; fn cmp(a: i32, b: i32) -> Ordering { if a < b { Ordering::Less }...

Lambda Expression Parameters/declaration

java,function,math,lambda,expression
I have been signed up for a while and don't usually post unless I really cannot find an answer, and now, I feel quite stuck. I have only recently started getting familiarized with java Lambda expressions (mainly the function ones) such as BinaryOperator and Bifunction..) I was looking at the...

Conditionally display an element with ng-if

javascript,angularjs,expression
I'm trying to display an expression on my webpage but only if the variable is existing. So at the moment I have, <ul class="nav navbar-nav navbar-right"> <li ng-if="displayUsername()">{{userTest}}</li> </ul> and in my controller I have, $scope.displayUsername = function () { $scope.userTest = authService.GetUsername(); } The service returns a value of...

C# linq group By on field and result string? [closed]

c#,linq,dynamic,expression,group
how to write dynamic groupby with selectfieldString and resultFieldString? sample: public class Customer { public int Id; public string Name; public string LastName; public decimal Amount; } var lst = new List<Customer>(); lst.Add(new Customer { Id = 1, Name = "vahid", LastName = "Aghilpour", Amount = 15 }); lst.Add(new Customer...

Return IQueryable from my method? Is it the right way to do it?

c#,linq,expression,iqueryable
I just spent some time to find how to return an IQueryable from a method... and I'm still wondering if it is the right way to do it. Here is my repository class: public class CarRepository : ICarRepository { // Fake entities private IList<Car> _entities = new List<Car>() { new...

combine multiple expressions in R into one big expression

r,expression,eval
I am new to R expression handling. I am stuck with below problem. Any input is appreciated. I am trying to generate two individual equations and combine them into one expression and pass it to an algorithm to find optimal value. OLD_PRICE ELAST Units 1 59.98 1.3 151 2 59.98...

Logstash grok pattern for WSO2 log message

regex,wso2,expression,wso2esb,logstash-grok
I am currently working with Logstash. I want to parse WSO2 ESB log statement using grok. I have tried different patterns but didn't succeed. Can anyone help me out to write custom pattern for WSO2 ESb log statement. Here is the sample log message: TID: [0] [ESB] [2015-02-25 12:35:18,719] INFO...

Get random expression generator

javascript,node.js,expression,connect
I have a function that creates random integers but I am trying to refactor it to create random addition expressions instead. It's currently only still generating single integers. Then the consumer needs to log the sum of the random expressions that the producers are making. It's a work off of...

linq expression for dates filtered on Day, Month and Year

c#,linq,lambda,expression
No data found using EQUAL? because of time difference? Can someone show me how to create valid expression for date? Table UserId Username DateCreated 466 [email protected] 5/10/1980 5:18:18 AM 467 [email protected] 5/10/1980 5:18:18 AM 502 [email protected] 5/10/1980 5:18:18 AM 534 [email protected] 5/10/1980 5:18:18 AM 535 [email protected] 5/10/1980 5:18:18 AM 570...

C# Expression Call, Can't seem to get the method info and parameters correct

c#,.net,reflection,lambda,expression
Expression> lambda = Expression.Lambda >(methodCall, allParameters);Here is the error: An exception of type 'System.ArgumentException' occurred in... Additional information: Expression of type 'System.Func`2[Business.Entities.SlateEmployee,System.Boolean]' cannot be used for return type 'System.Boolean' Can anyone see what is wrong with my code. public class ClearValueAction : ActionRuleBase { /// <summary> /// Virtual method to...

Implementing user-defined arithmetic functions

prolog,expression,iso-prolog
How can I add a function (e.g., hammingweight) and use it in expressions occuring in the right-hand side is some (is)/2 goal? Could something like goal_expansion or term_expansion help here? I acknowledge that this is not a big feature, but it could increase readability of some of my Prolog programs....

Why the pressence of Expression itself among method parameters makes method slow in C#

c#,performance,lambda,expression,compiler-optimization
Please, consider to methods: private void FastMethod(string param) { } private void SlowMethod<T>(Expression<Func<T>> expression) { } And the following test: [TestMethod] public void Test() { var stopwatch = new Stopwatch(); stopwatch.Start(); for (int i = 0; i < 1000000; i++) { this.FastMethod("TestContext"); } TestContext.WriteLine("Fast time: " + stopwatch.ElapsedMilliseconds); stopwatch.Restart(); for...