Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
See the earliest F# file you have written
open System.IO
let sourceDir = [ __SOURCE_DIRECTORY__ ]
let getFiles searchPattern dir =
seq {
yield! Directory.EnumerateFiles(dir, searchPattern)
}
let log x =
printfn "%A" x
x
// http://www.fssnip.net/pi/title/Recursively-find-all-files-from-a-sequence-of-directories
let rec getAllFiles f dirs =
if Seq.isEmpty dirs then Seq.empty else
seq { yield! dirs |> Seq.collect f
yield! dirs
|> Seq.collect Directory.EnumerateDirectories
|> Seq.filter (fun x ->
let dirName = Path.GetFileName x
[ "node_modules"; ".git"; "bin"; "obj"; "vendors"; "themes"; "packages"; "VisualStudio2010" ]
|> List.contains dirName
|> not )
|> fun x -> if Seq.isEmpty x then Seq.empty else (getAllFiles f x) }
let getFileDates () =
let FSharp = getFiles "*.fs?"
getAllFiles FSharp sourceDir
|> Seq.map (fun x ->
let creationTime = File.GetLastWriteTime x
x, creationTime
)
|> Seq.toArray
do
getFileDates ()
|> Seq.minBy ( fun (filename, date) -> date )
|> (printfn "%A")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment