reduce fn acc [] = acc
reduce fn acc (x:xs) = do 
  let accu = fn acc x 
  reduce fn accu xs

main = do
  let nums = [1..5]
  print $ nums
  print $ reduce (+) 0 nums
  print $ reduce (*) 1 nums

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: