fork download
  1. let GetVowels c =
  2. match c with
  3. | 'a' | 'e' | 'i' | 'o' | 'u' -> c.ToString()
  4. | _ -> ""
  5.  
  6. let GetConsonants c =
  7. match c with
  8. | ' ' -> ""
  9. | _ when GetVowels c = "" -> c.ToString()
  10. | _ -> ""
  11.  
  12. let Disemvowel str =
  13. let FindConsonants = String.collect GetConsonants
  14. let FindVowels = String.collect GetVowels
  15.  
  16. (FindConsonants str, FindVowels str)
  17.  
  18. let PrintDisemvoweledCollections (input: string) =
  19. let input = input.ToLower()
  20. let PrintCollection title collection =
  21. printfn "%-10s: %s" title collection
  22.  
  23. let consonants, vowels = Disemvowel input
  24.  
  25. PrintCollection "Input" input
  26. PrintCollection "Consonants" consonants
  27. PrintCollection "Vowels" vowels
  28. printfn ""
  29.  
  30. [<EntryPoint>]
  31. let main argv =
  32. PrintDisemvoweledCollections "two drums and a cymbal fall off a cliff"
  33. PrintDisemvoweledCollections "all those who believe in psychokinesis raise my hand"
  34. PrintDisemvoweledCollections "did you hear about the excellent farmer who was outstanding in his field"
  35. //System.Console.ReadLine() |> ignore
  36. 0 // return an integer exit code
Success #stdin #stdout 0.12s 11920KB
stdin
Standard input is empty
stdout
Input     : two drums and a cymbal fall off a cliff
Consonants: twdrmsndcymblfllffclff
Vowels    : ouaaaaoai

Input     : all those who believe in psychokinesis raise my hand
Consonants: llthswhblvnpsychknssrsmyhnd
Vowels    : aoeoeieeioieiaiea

Input     : did you hear about the excellent farmer who was outstanding in his field
Consonants: ddyhrbtthxcllntfrmrwhwststndngnhsfld
Vowels    : ioueaaoueeeeaeoaouaiiiie