Created
August 22, 2019 09:52
-
-
Save altbodhi/a9fc5a10d59bf63a46890501524e0dca to your computer and use it in GitHub Desktop.
F# implements write and writeln like as turbo pascal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open Microsoft.FSharp.Reflection | |
let readln = Console.ReadLine | |
let writeln = fun a -> | |
let args = if FSharpType.IsTuple(a.GetType()) then FSharpValue.GetTupleFields(a) else [|a|] | |
let fmt = args |> Array.indexed |> Array.fold (fun s e -> s + (sprintf "{%d}" (fst e))) "" | |
Console.WriteLine(fmt.Trim(), args) | |
let write = fun a -> | |
let args = if FSharpType.IsTuple(a.GetType()) then FSharpValue.GetTupleFields(a) else [|a|] | |
let fmt = args |> Array.indexed |> Array.fold (fun s e -> s + (sprintf "{%d}" (fst e))) "" | |
Console.Write(fmt.Trim(), args) | |
[<EntryPoint>] | |
let main argv = | |
write ("Ваше имя:") | |
let name = readln () | |
writeln ("Hello, ", name , "!") | |
readln () |> ignore | |
0 // return an integer exit code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment