Skip to content

Instantly share code, notes, and snippets.

@altbodhi
Created August 22, 2019 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save altbodhi/a9fc5a10d59bf63a46890501524e0dca to your computer and use it in GitHub Desktop.
Save altbodhi/a9fc5a10d59bf63a46890501524e0dca to your computer and use it in GitHub Desktop.
F# implements write and writeln like as turbo pascal
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