Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Function-composition/C-sharp/function-composition.cs
Normal file
18
Task/Function-composition/C-sharp/function-composition.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Func<int, int> outfunc = Composer<int, int, int>.Compose(functA, functB);
|
||||
Console.WriteLine(outfunc(5)); //Prints 100
|
||||
}
|
||||
static int functA(int i) { return i * 10; }
|
||||
static int functB(int i) { return i + 5; }
|
||||
class Composer<A, B, C>
|
||||
{
|
||||
public static Func<C, A> Compose(Func<B, A> a, Func<C, B> b)
|
||||
{
|
||||
return delegate(C i) { return a(b(i)); };
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue