Created
August 2, 2014 14:09
-
-
Save nobsun/66965c0102b174e818fe to your computer and use it in GitHub Desktop.
fold-zip 融合 ref: http://qiita.com/nobsun/items/37d6cc2505af0a3a252f
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(foldr (⊕) z .) . zipWith (⊗) | |
⇔ | |
foldr (⊛) (const z) | |
where | |
(x ⊛ k) [] = z | |
(x ⊛ k) (y:ys) = (x ⊗ y) ⊕ k ys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sumtimes xs ys = sum $ zipWith (*) xs ys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sumtimes = (foldr (+) 0 .) . zipWith (*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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