[Haskell-cafe] annoying output
Ryan Bloor
ryanbloor at hotmail.com
Sun Dec 9 01:03:58 EST 2007
hi
The code below does almost what I want but not quite! It outputs...parseInt "12444a" gives...
[(EInt 1,"2444a"),(EInt 2,"444a"),(EInt 4,"44a"),(EInt 4,"4a"),(EInt 4,"a")]
What I want is: [(EInt 12444, "a")]
data Expr = EInt {vInt :: Int} -- integer values | EBool {vBool :: Bool} -- boolean values
parseInt :: Parser parseInt (x:xs) | (isDigit x && xs /= []) = [(EInt (read [x]),xs)] ++ parseInt xs | isDigit x && xs == [] = [(EInt (read [x]),[])] | otherwise = []
Thanks
Ryan
_________________________________________________________________
Who's friends with who and co-starred in what?
http://www.searchgamesbox.com/celebrityseparation.shtml
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071209/c7959ef5/attachment.htm
More information about the Haskell-Cafe
mailing list