Sunday, 2 February 2014

Create a Function and Pass the parameter for the function - F#

In this post we are going to see how to create and parameter function and call that function.Always specify the parameter after to that of fucntion variable name then start implement the function name. When call the function parameter must be pass to the next to the function name with a space, then the code next to the parameter will be consider as operations.


open System

let f x = 3*x + 4*x + 10

let intval = 3
let result = f (intval + 2)
Console.WriteLine("Result1 :- {0}",result)

let result2 = f intval + 2
printfn "Result2 :- %d" result2


                Result1 :- 45
                Result2 :- 33

In the following sample you can see the code results in two output, only the difference is pass the with out bracket , because the input is the combination of two values.

From this post you can learn how to create a function and pass the parameter to the function.

No comments:

Post a Comment