Lumen
functional programming language for .NET
functional programming language for .NET
let x = 7
println (if x > 9: "x > 9"
else: "x <= 9") //=> "x <= 9"
let persons = [["Alex", 20], ["Maya", 21]]
for [name, age]
in persons:
print
"Name: \(name) Age: \(age)"
let factorials () =
let factorial 0 =
1
let factorial n = n *
rec (n - 1)
for i
in 1..inf:
yield
factorial i
// This infinitie loop will be print factorials
for i
in factorials ():
println i
// Factorial with tail recursion and helper function
let fact n =
let fact 0 acc = acc
let fact n acc = tailrec (n-1) (acc*n)
fact n 1
println (fact 5) //=> 120