[Haskell-beginners] University project - weird problem

Renato dos Santos Leal renatodossantosleal at gmail.com
Wed Apr 21 21:21:39 EDT 2010


Thank you Daniel.
Thank you everyone that answerd you guys really saved me today =)

2010/4/21 Daniel Fischer <daniel.is.fischer at web.de>

> Am Donnerstag 22 April 2010 02:30:06 schrieb Renato dos Santos Leal:
> >
> > But there is still one problem that I haven't corrected:
> > printing the tag when there is only one keyword or identifier in the
> > line the case of beign the last one of the line is corrected but this
> > one I don't know how to do
>
>
> > pchave :: String -> String -> IO ()
> > pchave (x:xs) ys
> >    | x `notElem` listA = pchave xs (ys++[x])
> >    | otherwise = pPCouI (x:xs) ys
>
> When you're collecting an identifier or keyword, stop when you encounter a
> newline.
>
> >
> > pPCouI :: String -> String -> IO ()
> > pPCouI (x:xs) z
> >    | membroPC z = do{ putStr (z ++ " <palavra chave>\n") ; le_bloco
> > (x:xs)} | otherwise = do{putStr z ; putStr " <identificador>\n" ;
> > le_bloco (x:xs)}
> >
>
> By the way,
>
> function :: a -> Bool
> function x
>    | condition = True
>    | otherwise = False
>
> is rather clumsy,
>
> function = condition
>
> is better.
>
> > membroPC :: String -> Bool
> > membroPC x
> >    | x `elem` listPC = True
> >    | otherwise = False
> >
>
> membroPC = (`elem` listPC)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100421/cf519e31/attachment.html


More information about the Beginners mailing list