[Haskell-cafe] take the keywords from a string

Sara Kenedy sarakenedy at gmail.com
Sat Jun 17 20:43:41 EDT 2006

Sorry, I am not clear at some point in your answer:

1) The function
lex :: String -> [(String,String)]
filter :: (a -> Bool) -> [a] -> [a]
So, I did not see how filter can use the list of tuple string of lex.

Sorry if the question seems ridiculous. Thanks.


On 6/17/06, Neil Mitchell <ndmitchell at gmail.com> wrote:
> Hi Sara,
> > This function will take the input as a string and return a list of
> > keywords taken from the input string and they  are elements of
> > ListOfKeywords. The order of the result list is sequenced as: the last
> > keyword found is set as the first element of the list, and so on.
> It looks like your language is quite Haskell like, so you can use the
> built in lex function to split a string into a list. Then a simple
> filter (`elem` listOfKeywords) will pick out the keywords for you.
> As for the ordering, maybe you want to apply reverse at the end?
> Thanks
> Neil

More information about the Haskell-Cafe mailing list