Skip to content

Define function

CodingUnit edited this page Nov 30, 2011 · 3 revisions

Define function

  • Category: Defining Operator

  • Description: define a function and composite functions and pipeline

  • Code:

 using System.Console;

def localFunction() {

           def f1(a) { a + 1 }
           def f2 = _ * 10; // partial application of operator "*"
           def ff = f1 >> f2;
           def r = ff(3);
           def r1 = 3 |> f1 |> f2;
           WriteLine($"result = $r and result1 = $r1");
           WriteLine($"is equal $(r == r1)")

}

localFunction() ```

-   Execution Result:

```nemerle
 result = 40 and result1 = 40 is equal True ```

-   Copyright

Samples used from “F\# 3.0 Sample Pack”
(<http://fsharp3sample.codeplex.com/>) at Codeplex OpenSource Community
for non-commercial usage. All copyrights and authorship on materials
this publication based on, is belongs to Microsoft corp. Copyright
&copy; 2006-2011 Microsoft Corporation, . All rights reserved. Copyright
and autorship for materials in Nemerle language belongs to Nemerle
Project Team. Copyright &copy; 2008-2011 Nemerle Project Team. All
rights reserved.
Clone this wiki locally