diff options
author | Joris | 2017-07-24 20:21:20 +0200 |
---|---|---|
committer | Joris | 2017-07-24 20:21:20 +0200 |
commit | ed5b3e04ba9d201efee55c9f47ca159e48cafb3d (patch) | |
tree | cea5ce7c28cd363b58e7ff9bef58c2d3dea9182c | |
parent | 1558cc8ec1d532fd827ab0a3fb056b90090d8daf (diff) |
Move code in parser
-rw-r--r-- | js/src/Parser.purs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/js/src/Parser.purs b/js/src/Parser.purs index cad9f1b..787c09e 100644 --- a/js/src/Parser.purs +++ b/js/src/Parser.purs @@ -43,14 +43,6 @@ textWithNumberParser = do end <- String.fromCharArray <$> Array.many Parser.anyChar pure { begin: begin, number: num, end: end } -numberFromIntArray :: Array Int -> Int -numberFromIntArray xs = - Array.range 0 (Array.length xs - 1) - # map (Int.pow 10) - # Array.reverse - # Array.zipWith (*) xs - # Array.foldl (+) 0 - notDigit :: Parser String Char notDigit = Parser.satisfy (not <<< isDigit) @@ -64,6 +56,14 @@ numberParser = do pure $ Int.toNumber decimals / Int.toNumber (Int.pow 10 (Array.length digits)) pure (Int.toNumber whole + Maybe.fromMaybe 0.0 decimal) +numberFromIntArray :: Array Int -> Int +numberFromIntArray xs = + Array.range 0 (Array.length xs - 1) + # map (Int.pow 10) + # Array.reverse + # Array.zipWith (*) xs + # Array.foldl (+) 0 + digit :: Parser String Int digit = map (\c -> Char.toCharCode c - zeroCode) $ Parser.satisfy isDigit |