summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2013-02-28 20:29:28 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2013-02-28 20:29:28 +0000
commit47d52a15ce9b2f03abb7ed676b031b340c4d5c72 (patch)
treee469403983e220496fb558beee00adb79693ae1f
parent396239490bf2d64abbae75abb02b4dc03e0ab0c2 (diff)
downloadcalculator-47d52a15ce9b2f03abb7ed676b031b340c4d5c72.tar.bz2
Parse positive integers
-rw-r--r--calculator.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/calculator.hs b/calculator.hs
index 7753022..ecdbff8 100644
--- a/calculator.hs
+++ b/calculator.hs
@@ -1,8 +1,14 @@
import Text.Parsec
import Text.Parsec.String
+parseNumber :: Parser Int
+parseNumber = do
+ n' <- many1 $ oneOf "0123456789"
+ return (read n')
+
calculation :: Parser Int
-calculation = return undefined
+calculation = do
+ parseNumber
calculate :: String -> String
calculate s =