
Hi everybody, it's my first message on this ML :) I don't know if it's appropriate to post this here but I would like to have some feedback with one of my first Haskell code. I've been inspired by a recent Numberphile video ( https://www.youtube.com/watch?v=HJ_PP5rqLg0) how explain the "Russian Peasant" algorithm to do multiplication (here in a nutshell : https://www.wikihow.com/Multiply-Using-the-Russian-Peasant-Method) So I decided I give it a go in Haskell, here is my solution, I appreciate if you give me some feedback on how to improve this code (make it more "idiomatic Haskell") NB : I apologize if it's not the right place to ask this kind of review ... in that case, where can I post this ? Thanks ! module DivRusse where main :: IO () main = do putStrLn "13 x 12 is" print $ russmul 13 12 russmul :: Int -> Int -> Int russmul a b = let filteredPair = filter (\pair -> (fst pair) `mod` 2 /= 0 ) $ (a,b) : russmulList a b in foldr (\pair acc -> snd pair + acc) 0 filteredPair russmulList :: Int -> Int -> [(Int, Int)] russmulList 1 _ = [] russmulList a b = let a' = a `div` 2 b' = b * 2 in (a', b') : russmulList a' b'