public static IValue make(Func <int, int> val) { Func <IValue, IValue> func = f => { return(ValueFactory.make(val(f.Get <int>()))); }; return(new Value(Type.Of(ValueType.FUNCTION), func)); }
private Func <IValue, IValue> makeListTypeChecker(IEnumerable <IValue> types) { Func <IValue, IValue> typeChecker = l => { var typeCheck = new TypeChecker(ValueFactory.make(types)); return(ValueFactory.make(typeCheck.Check(l))); }; return(typeChecker); }
public ListType(IValue types, String description) { if (!types.Type.Check(ValueType.LIST)) { throw new TypeException("List type must be actually a list!"); } this.predicate = ValueFactory.make(makeListTypeChecker(types.Get <IEnumerable <IValue> >())); this.friendlyName = description; this.creationList = types; }
public static IValue make(Func <IValue, IValue> val, IValue paramType = null, IValue returnType = null) { if (paramType == null) { paramType = ValueFactory.make(Type.Of(ValueType.ANY)); } if (returnType == null) { returnType = ValueFactory.make(Type.Of(ValueType.ANY)); } return(new FunctionValue(val, paramType, returnType)); }
public FunctionValue(Func <IValue, IValue> func, IValue parameterType) { this.innerFunction = func; this.parameterType = parameterType; this.returnType = ValueFactory.make(new Type(ValueType.ANY)); }
public bool Check(IValue val) { return(Check(val.Type) || (val.Type.RawTypeOf == RawTypeOf && Predicate.Operator("()", val).Equals(ValueFactory.make(true)))); }
public ListType(IEnumerable <IValue> types, String description) { this.predicate = ValueFactory.make(makeListTypeChecker(types)); this.friendlyName = description; this.creationList = ValueFactory.make(types); }