Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open System
- open System.IO
- open System.Collections.Generic
- open System.Collections.Concurrent
- open System.Text
- let capitals = ConcurrentDictionary<string, string>()
- capitals.["Italy"] <- "Rome"
- let x = capitals.["Italy"]
- //Simple word count example
- let wordCount dirPath wildCard =
- let wordCounts = Dictionary<string, int>()
- let processFile fileName =
- let text = File.ReadAllLines(fileName)
- text.Split ([|'.'; ' '; '\r'|], StringSplitOptions.RemoveEmptyEntries)
- |> Array.map(fun w -> w.Trim())
- |> Array.filter(fun w -> w.Length > 2)
- |> Array.iter(fun w ->
- let ok, count = wordCounts.TryGetValue(w)
- if ok then
- wordCounts.[w] <- count + 1
- else
- wordCounts.[w] <- 1)
- Directory.EnumerateFiles(dirPath, wildCard)
- |> Seq.iter processFile
- wordCounts
- |> Seq.sortBy(fun kv -> kv.Value)
- [<EntryPoint>]
- let main argv =
- printfn "%A" argv
- 0 // return an integer exit code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement