7 people like it.

Abstract Console.ReadLine as an infinite sequence

Abstracts console input as an infinite sequence of lines of text

1: 
2: 
3: 
4: 
5: 
6: 
7: 
open System;

let echo line = printfn "You said %s" line

let infiniteLines = Seq.initInfinite (fun _ -> Console.ReadLine())

Seq.iter echo infiniteLines
namespace System
val echo : line:string -> unit

Full name: Script.echo
val line : string
val printfn : format:Printf.TextWriterFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
val infiniteLines : seq<string>

Full name: Script.infiniteLines
module Seq

from Microsoft.FSharp.Collections
val initInfinite : initializer:(int -> 'T) -> seq<'T>

Full name: Microsoft.FSharp.Collections.Seq.initInfinite
type Console =
  static member BackgroundColor : ConsoleColor with get, set
  static member Beep : unit -> unit + 1 overload
  static member BufferHeight : int with get, set
  static member BufferWidth : int with get, set
  static member CapsLock : bool
  static member Clear : unit -> unit
  static member CursorLeft : int with get, set
  static member CursorSize : int with get, set
  static member CursorTop : int with get, set
  static member CursorVisible : bool with get, set
  ...

Full name: System.Console
Console.ReadLine() : string
val iter : action:('T -> unit) -> source:seq<'T> -> unit

Full name: Microsoft.FSharp.Collections.Seq.iter

More information

Link:http://fssnip.net/2I
Posted:6 years ago
Author:fholm
Tags: console , seq