次の方法で共有


Welcome to F#

In this post, I will introduce you to F#, a multi-paradigm .NET programming language that already attracted my attention. Lets try by downloading and installing it. I am using Version 1.9.6.2 at the time of this posting. For you who wants to follow me in F# exploration, I strongly recommend you to download and print the F# Language Specification and regularly visit F# Official MSDN Website.

FS01 
For you who already installed Visual Studio 2008, the F# installer will give you project templates for F# Application, Library and Tutorial. I am using VS 2008 Team Suite, and here is my VS 2008 looks like when I created new F# App project. Don't worry too much if you don't have VS 2008, you can use any text editor to write your codes then paste your code in MSR F# interactive console, fsi.exe. FS04

VS 2008 provides compilation environment using MSBuild extension. You can find the definition F# extension at Microsoft.FSharp.Targets and FSharp.Build.dll at Program Files/MSBuild folder. What you need to do in VS 2008 is just create new F# App project, write codes, then build. Let start by simple equation:

// Turn on the lightweight syntax
#light
// Open .NET standard namespaces
open System
// A very simple constant integer
let i1 = 1
// A second very simple constant integer
let i2 = 2
// Add two integers
let i3 = i1 + i2
// Functions on integers f(x) = 10*x*x - 15*x + 13
let f x = 10*x*x - 15*x + 13

// The result of a simple computation
let result = f (i3 + 400)

// Print an integer
printfn "Result = %d" result

I believe you can easily understand above codes intuitively. The first line of the codes is an option to turn on F# lightweight syntax option. This option allows us to write code that looks and feels simpler by omitting recurring F# tokens such as, done, ; (semicolon), ;; (double semicolon), begin, and end. The option instructs F# compiler to use the indentation of F# code to determine where constructs start and finish.

Writing function in functional language is very straight forward. In our case, I wrote f x (f space x) as a function of x. Then I can reuse f for any input values. I will not explain language aspect in this first post, but I will do it in some tutorial series later on. My current F# reading is:
FS06 FS07

Good News.
The F# and .NET libraries include support for parallel and asynchronous programming. One way to write these kinds of programs is to use F#-facing libraries such as F# Asynchronous Workflows. Also, we can combine F# Async Workflow with the Parallel Extension for .NET, to implement task parallelism, I/O parallelism and message passing agents.

Stay tuned!. Lets make IT happen in NEPAL.

Cheers, RAM
My other blogs : https://blogs.msdn.com/risman

Comments