Skip to content

Instantly share code, notes, and snippets.

@nobsun
Created August 2, 2014 14:09
Show Gist options
  • Save nobsun/66965c0102b174e818fe to your computer and use it in GitHub Desktop.
Save nobsun/66965c0102b174e818fe to your computer and use it in GitHub Desktop.
(foldr (⊕) z .) . zipWith (⊗)
foldr (⊛) (const z)
where
(x ⊛ k) [] = z
(x ⊛ k) (y:ys) = (x ⊗ y) ⊕ k ys
sumtimes xs ys = sum $ zipWith (*) xs ys
sumtimes = (foldr (+) 0 .) . zipWith (*)
sumtimes = foldr (⊛) (const 0)
where
(x ⊛ k) [] = 0
(x ⊛ k) (y:ys) = (x * y) + k ys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment