Snippets

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

You are viewing an old version of this snippet. View the current version.
Revised by Cameron Presley 346df2e
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" 
HTTPS SSH

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