How to resolve the algorithm Currying step by step in the Nemerle programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Currying step by step in the Nemerle programming language

Table of Contents

Problem Statement

Create a simple demonstrative example of Currying in a specific language.
Add any historic details as to how the feature made its way into the language.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Currying step by step in the Nemerle programming language

Source code in the nemerle programming language

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))")
    }
}


  

You may also check:How to resolve the algorithm Active object step by step in the ooRexx programming language
You may also check:How to resolve the algorithm Zig-zag matrix step by step in the Arturo programming language
You may also check:How to resolve the algorithm Events step by step in the Erlang programming language
You may also check:How to resolve the algorithm Playing cards step by step in the Factor programming language
You may also check:How to resolve the algorithm Deconvolution/1D step by step in the D programming language