boolean expression with "contains" operator

Jan 14, 2008 at 7:44 PM
First of all, I like your program. It's very fast and easy to use. Maybe this is something I missed. Is there anyway you can do a boolean expression with "contains" operator? For example, if I pass in my datatype that contains a string[], can I do a "contains" check and returns a boolean value?
Jan 16, 2008 at 3:25 AM
Right now, there is no contains operator. I'm planning on putting one in in the next release. I'm still debating what the syntax will look like (either "var in (1, 2, 3)" or "in(a, 1, 2, 3)").

In the mean time, you can code a contains function and import it into the expression to get the same functionality:
public static class CustomFunctions
   public static bool Contains(string[] arr, string value)
       return System.Array.IndexOf(arr, value) != -1;

And then use it in an expression:
ExpressionContext context = new ExpressionContext();
context.Variables.Add("arr", new string[] {"a", "b", "c"});
context.Variables.Add("value", "flee!");
IDynamicExpression e = ExpressionFactory.CreateDynamic("contains(arr, value)", context);
bool result = (bool)e.Evaluate();
Feb 6, 2008 at 2:34 AM
The In operator is implemented in Flee- You can find the documentation here