F#

Mono F#

Installation

Ubuntu
apt install fsharp

Examples

Fibonacci Numbers
// Fibonacci Numbers
(* if else
let rec fib n = 
    if n < 2 then
        n
    else
        fib(n - 2) + fib(n - 1)
*)
let rec fib = function
    | n when n=0 -> 0
    | n when n=1 -> 1
    | n -> fib(n - 2) + fib(n - 1)

[<EntryPointAttribute>]
let main (args) = 
    let n : int = int args.[0]
    printf "%d" (fib(n))
    0

(*
    example
        compile:
            fsharpc --optimize+ fib.fs
        run:
            ./fib.exe 39
            or
            mono fib.exe 39
*)