fsharp 2.0.0
Version of implementation Mono F# of programming language F#A version of Mono F# compiler.
Examples:
Hello, World! - F# (205):
printfn "Hello, World!"
Factorial - F# (206):
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 - F# (207):
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 "..."
Comments
]]>blog comments powered by Disqus
]]>