Couple of years ago I had a good time practicing Go by solving a number of programming challenges on Hackerrank. This time I will try solve functional challenges using F#.
There is the first one:
Your task is to scan two numbers, A and B from STDIN, and print the sum A+B on STDOUT.
It is just a basic challenge to get convenient with solution submision and language basics. The code looks pretty much C#:
open System [<EntryPoint>] let main argv = let a = Console.ReadLine() |> int let b = int(Console.ReadLine()) printfn "%d" (a+b) 0 // return an integer exit code
Console.ReadLine() |> int and
int(Console.ReadLine()) are equivalent forms.
a |> b is just