Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: count words which contain all vowels in a file.

by Fletch (Bishop)
on Apr 01, 2010 at 14:34 UTC ( [id://832314]=note: print w/replies, xml ) Need Help??


in reply to Re^2: count words which contain all vowels in a file.
in thread count words which contain all vowels in a file.

I don't think you really mean any other way . . .

#!/usr/bin/env runhaskell module Main where import System (getArgs) import qualified Data.ByteString.Lazy.Char8 as L has_all_vowels :: L.ByteString -> Bool has_all_vowels word = map (\pred -> pred word) predicates == [True,True,True,True,True] where predicates = (map (\c -> L.elem c) "aeiou") words_with_all_vowels = filter has_all_vowels . L.lines main :: IO () main = do [infile] <- getArgs contents <- L.readFile infile mapM_ L.putStrLn $ words_with_all_vowels contents -- -- $ {time ~/vowels.hs /usr/share/dict/words} | wc -l -- ~/vowels.hs /usr/share/dict/words 0.80s user 0.04s system 99% cpu +0.852 total -- 5942 --

Addendum: Mine doesn't handle AEIOU correctly, but then neither does the OP's.

The cake is a lie.
The cake is a lie.
The cake is a lie.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://832314]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (1)
As of 2024-04-25 01:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found