Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/First-class-functions/C-sharp/first-class-functions.cs
Normal file
22
Task/First-class-functions/C-sharp/first-class-functions.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var cube = new Func<double, double>(x => Math.Pow(x, 3.0));
|
||||
var croot = new Func<double, double>(x => Math.Pow(x, 1 / 3.0));
|
||||
|
||||
var functionTuples = new[]
|
||||
{
|
||||
(forward: Math.Sin, backward: Math.Asin),
|
||||
(forward: Math.Cos, backward: Math.Acos),
|
||||
(forward: cube, backward: croot)
|
||||
};
|
||||
|
||||
foreach (var ft in functionTuples)
|
||||
{
|
||||
Console.WriteLine(ft.backward(ft.forward(0.5)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue