Sunday, February 24, 2008

FSharp - Discovering

I must admit that after Python, It has been difficult for me to find another
language which was as attractive as Python.
I think F# will be this one.


#light

open System

let print x = printfn "%A" x
let sub a b = a - b

let halfway a b =
let dif = b -a
let mid = dif/2
let z = mid + a
z

let y = (fun x y -> x + y) 1 2

let rec fib x =
match x with
| 1 -> 1
| 2 -> 1
| x -> fib (x-1) + fib (x-2)

let UnAnApres =
DateTime.Now + new TimeSpan(365,0,0,0,0)

let print_List l =
List.iter print_string l
print_string "\n"

let shortHand = ["apples"; "pairs"]

shortHand |> printf "%A"

read_line ()

No comments:

Post a Comment