fork(2) download
  1. let vowels = "aeiou".ToCharArray()
  2. let IsVowel letter = Array.exists (fun vowel -> letter = vowel) vowels
  3. let ListToString lst =
  4. let sb = new System.Text.StringBuilder()
  5. sb.Append((Array.ofList lst)).ToString()
  6.  
  7. let Disemvoweler (input: string) =
  8. let chars = input.ToLower().ToCharArray()
  9. let consonants, vowels =
  10. Array.fold (fun (consonants, vowels) c ->
  11. if IsVowel c then consonants, c::vowels
  12. elif c <> ' ' then c::consonants, vowels
  13. else consonants, vowels
  14. ) ([], []) chars
  15. List.rev consonants, List.rev vowels
  16.  
  17. let Disemvowel (input: string) =
  18. let consonants, vowels = Disemvoweler input
  19. printfn "%s" input
  20. printfn "%s" (ListToString consonants)
  21. printfn "%s" (ListToString vowels)
  22. printfn ""
  23.  
  24. [<EntryPoint>]
  25. let main argv =
  26. Disemvowel "two drums and a cymbal fall off a cliff"
  27. Disemvowel "all those who believe in psychokinesis raise my hand"
  28. Disemvowel "did you hear about the excellent farmer who was outstanding in his field"
  29. //System.Console.ReadLine() |> ignore
  30. 0 // return an integer exit code
Success #stdin #stdout 0.08s 11688KB
stdin
Standard input is empty
stdout
two drums and a cymbal fall off a cliff
twdrmsndcymblfllffclff
ouaaaaoai

all those who believe in psychokinesis raise my hand
llthswhblvnpsychknssrsmyhnd
aoeoeieeioieiaiea

did you hear about the excellent farmer who was outstanding in his field
ddyhrbtthxcllntfrmrwhwststndngnhsfld
ioueaaoueeeeaeoaouaiiiie