Snippets

Cameron Presley F# - Find Unique line entries in a file

Created by Cameron Presley last modified Cameron Presley
open System.IO

let readLines (filePath:string) = seq {
    use reader = new StreamReader (filePath)
    while not reader.EndOfStream do
        yield reader.ReadLine ()
}

let linesRead = readLines "your_file_name_here.txt"

linesRead |> Seq.length |> printfn "There are %i total lines"
linesRead |> Seq.distinct |> Seq.length |> printfn "There are %i unique entries" 

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.