expression

Is there any PHP or JavaScript math expression formatters (which adds brackets) ?

Google Calculator formats math expressions this way: 2+2/2 ---> 2 + (2 / 2) 2+2/2*PI ---> 2 + ((2 / 2) * PI) In others words - it adds brackets. Is there any similar PHP or JavaScript solutions to do the same thing? ...

Can I use Calendar in a Struts2 Validator Annotation?

Is it possible to use the java.util.Calendar in a Struts2 IntRangeFieldValidator? The following code does not produce any OGNL errors but does not work either. I'm trying to create a validation rule for a year range, min= 1970 and max= current calendar year. @RequiredFieldValidator(message="Year cannot be blank") @IntRangeFieldValidato...

ML Expression, help line by line

val y=2; fun f(x) = x*y; fun g(h) = let val y=5 in 3+h(y) end; let val y=3 in g(f) end; I'm looking for a line by line explanation. I'm new to ML and trying to decipher some online code. Also, a description of the "let/in" commands would be very helpful. ...

Get delegate arguments inside delegate

Hi all, Could someone please help me to understand how to get all parameters passed to delegate inside delegate itself? I have class : public class ShopManager : ShopEntities { public ShopManager getWhere(Func<Object, Object> dataList) { var x = dataList.???; // how to get arguments? return this; } pu...

Can I define a method to accept EITHER a Func<T> OR an Expression<Func<T>>?

If I attempt to write two overloads of a method, one accepting an Expression<Func<T>> parameter and another accepting a Func<T>, I will get a compiler error on trying to call the method with a lambda expression because the two signatures create ambiguity. The following would be problematic, for example: Method(() => "Hello"); // Is that...

Create expression with different types

How can I change if (propType.PropertyType == typeof(string)) and if (propType.PropertyType == typeof(int)) to something more dynamic? private void button2_Click(object sender, EventArgs e) { var lista = _pessoas.AsQueryable(); if (textBox2.Text != "") { var param = Expression...

What are the parsing rules for expressions in C?

How can I understand the parsing of expressions like a = b+++++b---c--; in C? I just made up the expression above, and yes, I can check the results using any compiler, but what I want to know is the ground rule that I should know to understand the parsing of such expressions in C. ...

Best sandboxed expression language thats Java

Firstly i want something that includes support for math expressions, including operator priority string expressions, like substring, etc supports named functions this allows me to decorate and control exactly who and what functions can be executed. read/write variables that are "typeless" / allow type conversion in a controlled man...

Short conditions, java

Hi, i want to test if current char current is not ',', '-', '.' or ' ' Is there a shorter expression for: if((current != ' ') || (current != '.') || ...) any ideas? EDIT: I am just allowed to use the methods nextChar and getChar. I have to loop through the chars. import java.io.FileInputStream; import java.io.IOException; import j...

Regular expression in C# , is this possible?

I never use regular expression before and plan to use it to solve my problem but not quite sure whether it can help me. I have a situation where I need store a rule or formula to build string values like following examples in a database field then retrieve this rule and build the string value. FacilityCode + Left(ModelNO,2) Right(PO,3...

Select Anonymous type with Dynamic Expression API

I'm using Dynamic Expression API (System.Linq.Dynamic) with Linq to Entities. My linq statement is below. var query = this.db.Products.AsQueryable() .Where(strCondition) .OrderBy("ProductNumber") .Select("new(ProductNumber, ProductDescription, ProductCategory.Name)"); Now that I have the "query", I do...