Declaring and calling inner functions sample - vilinski/nemerle GitHub Wiki
Declaring and calling inner functions
Category: Functions
Description: Declaring and calling functions within the body of another function
Code:
using System.Console;
def FunctionSample2()
{
def even(n) { n %2 == 0 }
def tick(x) { WriteLine($"tick $x") }
def tock(x) { WriteLine($"tock $x") }
def choose(f, g, h, x) { if (f(x)) g(x) else h(x) }
def ticktock = choose(even, tick, tock, _); // ticktock is a function built out of other functions using 'choose'foreach (i in [0..10])
ticktock(i);
}
FunctionSample2();