Mono F#

Implementation of programming language F#

An open-source implementation of F#.

Examples:

Hello, World!:

Example for versions fsharp 2.0.0
printfn "Hello, World!"

Factorial:

Example for versions fsharp 2.0.0

This example uses recursive definition of factorial, expressed in procedural paradigm.

factorial defines the actual factorial-calculating routine, and printFact defines the routine that outputs calculated factorials in required format.

let rec factorial n =
    match n with
    | 0 -> 1
    | _ -> n * factorial (n - 1)

let rec printFact n  =
    match n with 
    | 0 -> printfn "0! = 1"
    | _ -> printFact (n-1)
           printfn "%d! = %d"  n (factorial (n))
           
printFact(16)

Fibonacci numbers:

Example for versions fsharp 2.0.0

This example uses straightforward recursive definition of Fibonacci numbers, expressed in procedural paradigm.

let rec fibonacci n =
    match n with
    | 1 | 2 -> 1
    | _ -> fibonacci (n-1) + fibonacci (n-2)

let rec printFib n  =
    match n with 
    | 1 -> printf "%d, " (fibonacci (n))
    | _ -> printFib (n-1)
           printf "%d, " (fibonacci (n))
           
printFib(16)
printfn "..."