Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #light
- open System
- open System.Linq
- open System.IO
- open Microsoft.FSharp.Linq
- let allowedChars = [|'a'; 'b'; 'o'; 'n'; 'i'; 'm'; 't'|]
- let dictionaryPath = "C:\\slowa.txt"
- let is_allowed_word word (allowedChars : char[]) =
- word |> Array.forall (fun letter -> allowedChars.Contains(letter))
- let findFunc = File.ReadAllLines(dictionaryPath)
- |> Array.filter (fun word -> is_allowed_word (word.ToArray()) allowedChars)
- |> Array.sortByDescending (fun w -> w.Length)
- let findFuncCSharpLike = File.ReadAllLines(dictionaryPath)
- .Where(fun word -> (word.All(fun letter -> allowedChars.Contains(letter))))
- .OrderByDescending(fun w -> w.Length)
- [<EntryPoint>]
- let main argv =
- findFunc |> Seq.iter(fun w-> printfn "%s" w)
- System.Console.ReadKey() |> ignore
- 0
Add Comment
Please, Sign In to add comment