Tag Archives: F# console I/O

F#: Reading From Console

open System

let readInput() =
   Seq.initInfinite (fun _ -> Console.ReadLine())
   |> Seq.takeWhile (fun s -> not (s.Equals("")))
   |> Seq.map int

There are a lot of ways to read information from the console, and with GUIs
having been around a long time, console I/O is not as big a deal as it
was years ago. For F#, this seems to be a good way to read integers from the command line, and then convert them from ASCII to int.

From a sequence, conversion is possible to an array or list.

Leave a comment

Filed under F#