From 6ca7b4eac84224f4935273df32f3f06a5ea2ef33 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Sat, 13 Dec 2025 11:24:46 +0000 Subject: [PATCH] Match `digitsToInt` to simpler Rust version --- haskell/Pre.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haskell/Pre.hs b/haskell/Pre.hs index c55e865..577eaac 100644 --- a/haskell/Pre.hs +++ b/haskell/Pre.hs @@ -102,7 +102,7 @@ digit :: (Token s ~ Char, Num b, MonadParsec e s f) => f b digit = fromIntegral . digitToInt <$> digitChar digitsToInt :: (Integral a) => [a] -> Int -digitsToInt = snd . foldr (\b (p, acc) -> (10 * p, acc + fromIntegral b * p)) (1, 0) +digitsToInt = foldl' (\acc d -> acc * 10 + fromIntegral d) 0 listIndex :: Int -> [a] -> Maybe a listIndex n =