public void Apply_Six() { var func = Curry.Apply <int, int, int, int, int, int, int>((a, b, c, d, e, f) => a + b + c + d + e + f); int value = -1; value = func(1)(0)(0)(0)(0)(0); Assert.AreEqual(1, value); value = func(1)(2)(0)(0)(0)(0); Assert.AreEqual(3, value); value = func(1)(2)(3)(0)(0)(0); Assert.AreEqual(6, value); value = func(1)(2)(3)(4)(0)(0); Assert.AreEqual(10, value); value = func(1)(2)(3)(4)(5)(0); Assert.AreEqual(15, value); value = func(1)(2)(3)(4)(5)(6); Assert.AreEqual(21, value); }
public ActionResult Delete(int CategoryId, int CurryId) { if (CategoryId > 0) { //write a LINQ query to select a category with an ID that is the same as the parameter CategoryId Ingredients category = db.Ingredients.First(val => val.ID == CategoryId); if (category == null) { return(HttpNotFound()); } if (CurryId > 0) { //write a LINQ query to select a movie with an ID that is the same as the parameter MovieId Curry curry = db.Curries.First(val => val.ID == CurryId); if (curry == null) { return(HttpNotFound()); } curry.Categories.Remove(category); db.SaveChanges(); } } return(View("Index", CreateAssignCategoryViewModel(CurryId))); }
public static Func <State, State> UpdateProcessing(Event processing) { return(Curry <Event, State, State> .New(UpdateProcessing)(processing)); }
public static Object LDiv(Object[] args) { return(Curry.MinTwo(StandardOperators.LDiv, args) ?? If.Is <Double, Double>(args, (y, x) => y / x) ?? If.Is <Double[, ], Double>(args, (y, x) => y.Divide(x))); }
/// <summary> /// Partially apply the first arg to a three parameter function /// </summary> public static Func <T2, Func <T3, T4> > Apply <T1, T2, T3, T4>(Func <T1, T2, T3, T4> func, T1 arg1) { return(Curry(func)(arg1)); }
public static Object Mod(Object[] args) { return(Curry.MinTwo(StandardOperators.Mod, args) ?? If.Is <Double, Double>(args, (y, x) => x % y) ?? If.IsNotNull(args, m => m.ToNumber(), (y, x) => x % y)); }
public static Func <State, State> OverlayOnEventStoreList(Func <State, ImList <Event> > getEventList) { return(Curry <Func <State, ImList <Event> >, State, State> .New(OverlayOnEventStoreList)(getEventList)); }
public static Func <State, State> UpdateGameState(GameState gameState) { return(Curry <GameState, State, State> .New(UpdateGameState)(gameState)); }
public static Func <State, State> Curry <T1, T2>(Func <T1, T2, State, State> handler, T1 arg1, T2 arg2) { return(Curry <T1, T2, State, State> .New(handler)(arg1)(arg2)); }
public static Object Abs(Object[] args) { return(Curry.MinOne(StandardOperators.Abs, args) ?? If.Is <Double[, ]>(args, x => Matrix.Abs(x)) ?? Math.Abs(args[0].ToNumber())); }
public static Object Type(Object[] args) { return(Curry.MinOne(StandardOperators.Type, args) ?? args[0].ToType()); }
public void TypeInference_EitherIdConstConst_CorrectType() { /* * id : a -> a * dot: (b -> c) -> (a -> b) -> a -> c * const - throw away b: a -> b -> a * eitherFunc: (a -> b) -> (c -> d) -> (a -> b) * eitherFunc: (a -> b) -> (c -> d) -> (c -> d) * * * All with free vars: * id: a -> a * dot: (b -> c) -> (x -> b) -> x -> c * const: y -> z -> y * eitherfunc: (d -> e) -> (f -> g) -> (d -> e) * (d -> e) -> (f -> g) -> (f -> g) */ /* * (((eitherfunc id) dot) const) * * (eitherfunc id) * [(d -> e) -> (f -> g) -> (d -> e)] (a -> a) * [(d -> e) -> (f -> g) -> (f -> g)] (a -> a) * * Gives: * d ~ a * e ~ a * thus: * (f -> g) -> (a -> a) * (f -> g) -> (f -> g) * * ((eitherfunc id) dot) * [(f -> g) -> (a -> a)] ((b -> c) -> (x -> b) -> x -> c) * [(f -> g) -> (f -> g)] (b -> c) -> (x -> b) -> (x -> c) * * Thus: (f -> g) ~ (b -> c) -> ((x -> b) -> x -> c) * thus: f ~ (b -> c) * g ~ ((x -> b) -> (x -> c)) * thus: * (a -> a) * (b -> c) -> ((x -> b) -> (x -> c)) * * * * (((eitherfunc id) dot) const): * [(a -> a)] (y -> (z -> y)) * [(b -> c) -> ((x -> b) -> (x -> c))] (y -> (z -> y)) * * Thus: case 1: * a ~ (y -> (z -> y) * Type is: (y -> z -> y) === typeof(const) * case2: * (b -> c) ~ (y -> (z -> y)) * thus: b ~ y * c ~ (z -> y) * ((x -> y) -> (x -> (z -> y)))) * = ((x -> y) -> x -> z -> y === mix of dot and const * */ var a = new Var("a"); var c = new Var("c"); var d = new Var("d"); var e = Funcs.Either(Funcs.Id, Funcs.Dot, Funcs.Const); var types = e.Types.ToList(); Assert.Equal(Curry.ConstructFrom(c, c, d), types[0]); Assert.Equal(Curry.ConstructFrom( c, // RESULT TYPE new Curry(a, c), a, d ), types[1]); }
public static Object Transpose(Object[] args) { return(Curry.MinOne(StandardOperators.Transpose, args) ?? If.Is <Double[, ]>(args, x => x.Transpose()) ?? args[0].ToNumber().ToMatrix()); }
public static Func <State, State> UnpackEventArchivesInRange(long oldestSpawnTime) { return(Curry <long, State, State> .New(UnpackEventArchivesInRange)(oldestSpawnTime)); }
public static Func <State, State> UpdateEventStoreProgress(Func <State, string> getProgress) { return(Curry <Func <State, string>, State, State> .New(UpdateEventStoreProgress)(getProgress)); }
public static Func <State, State> UpdateEventStoreProgress(string progress) { return(Curry <string, State, State> .New(Store.UpdateEventStoreProgress)(progress)); }
public static Func <State, State> UpdateEventStoreList(ImList <Event> eventStoreList) { return(Curry <ImList <Event>, State, State> .New(UpdateEventStoreList)(eventStoreList)); }
public static Func <IEnumerable <string>, string> Join(string separator) { return(Curry <string, IEnumerable <string>, string>(string.Join)(separator)); }
public static Func <State, State> UpdateEventArchives(ImList <EventArchive> eventArchives) { return(Curry <ImList <EventArchive>, State, State> .New(UpdateEventArchives)(eventArchives)); }
protected Object TryCurry(Object[] arguments) { return(Curry.Min(_maxParameters, _proxy, arguments)); }
public static Func <State, State> Curry <T>(Func <T, State, State> handler, T arg1) { return(Curry <T, State, State> .New(handler)(arg1)); }
/// <summary> /// Map Maybe T to Maybe R with mapper of arity 2 /// by currying /// </summary> public static Maybe <Func <T2, R> > Map <T1, T2, R>(this Maybe <T1> self, Func <T1, T2, R> mapper) => self.Map(Curry.curry(mapper));
public static Object Pipe(Object[] args) { return(Curry.MinTwo(StandardOperators.Pipe, args) ?? If.Is <Function>(args, f => f.Invoke(new[] { args[1] }))); }
public static Func <State, State> UnpackNewestEventArchive(ImList <EventArchive> eventArchives) { return(Curry <ImList <EventArchive>, State, State> .New(UnpackNewestEventArchive)(eventArchives)); }
public static Object Sub(Object[] args) { return(Curry.MinTwo(StandardOperators.Sub, args) ?? If.Is <Double, Double>(args, (y, x) => x - y) ?? If.Is <Double[, ], Double[, ]>(args, (y, x) => x.Subtract(y))); }
public static Func <State, State> OverlayOnEventStoreList(ImList <Event> eventList) { return(Curry <ImList <Event>, State, State> .New(OverlayOnEventStoreList)(eventList)); }
public static Object RDiv(Object[] args) { return(Curry.MinTwo(StandardOperators.RDiv, args) ?? If.Is <Double, Double>(args, (y, x) => x / y) ?? If.Is <Double, Double[, ]>(args, (y, x) => x.Divide(y))); }
public static Func <State, State> UnpackEventArchivesInRange(Func <State, long> getOldestSpawnTime) { return(Curry <Func <State, long>, State, State> .New(UnpackEventArchivesInRange)(getOldestSpawnTime)); }