diff options
Diffstat (limited to 'js/src')
-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 |