20 lines
383 B
Text
20 lines
383 B
Text
using System;
|
|
using System.Console;
|
|
|
|
module Curry
|
|
{
|
|
Curry[T, U, R](f : T * U -> R) : T -> U -> R
|
|
{
|
|
fun (x) { fun (y) { f(x, y) } }
|
|
}
|
|
|
|
Main() : void
|
|
{
|
|
def f(x, y) { x + y }
|
|
def g = Curry(f);
|
|
def h = Curry(f)(12); // partial application
|
|
WriteLine($"$(Curry(f)(20)(22))");
|
|
WriteLine($"$(g(21)(21))");
|
|
WriteLine($"$(h(30))")
|
|
}
|
|
}
|