Skip to content

Instantly share code, notes, and snippets.

@killerswan
Created September 8, 2011 20:39
Show Gist options
  • Save killerswan/1204618 to your computer and use it in GitHub Desktop.
Save killerswan/1204618 to your computer and use it in GitHub Desktop.
filtering a large file with a list of things
open System
open System.IO
// use an @ string
let list = @"C:\list.txt"
// initialize a reader
let reader = new StreamReader(list)
// create a list of lines
let lines = [ while not reader.EndOfStream do
yield reader.ReadLine () ]
// filter to only the version we care about, by string match
let isolateVersion (s: string) (a: string) = a.Contains(s)
// filter and then print each line
lines
|> List.filter (isolateVersion @"MYKEYWORD")
|> List.map (fun line -> printfn "%s" line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment