| using System; | |
| namespace Funcs { | |
| public static class Funcs { | |
| public static Func<A, C> Select<A, B, C>(this Func<A, B> f, Func<B, C> g) { | |
| return a => g(f(a)); | |
| } | |
| public static Func<C, B> SelectMany<A, B, C>(this Func<C, A> f, Func<A, Func<C, B>> g) { | |
| return a => g(f(a))(a); | |
| } | |
| public static Func<C, D> SelectMany<A, B, C, D>(this Func<C, A> f, Func<A, Func<C, B>> p, Func<A, B, D> k) { | |
| return SelectMany<A, D, C>(f, b => Select<C, B, D>(p(b), x => k(b, x))); | |
| } | |
| } | |
| class UseFunc { | |
| Func< | |
| Func<A, B, C> | |
| , Func<int, A> | |
| , Func<int, B> | |
| , Func<int, C> | |
| > | |
| use<A, B, C>() { | |
| return | |
| (f, a, b) => | |
| from aa in a | |
| from bb in b | |
| select f(aa, bb); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment