Foldl
December 31, 2019
product_td :: Num a => [a] -> a
product_td = _product 1
where
_product v [] = v
_product v (x:xs) = _product (v * x) xs
Note: The base case _product v [] = v
returns v
, which is the result of the recursed function calls.
or
product_td :: Num a => [a] -> a
product_td = foldl (*) 1