Last active
June 17, 2020 01:53
-
-
Save lumie1337/f438394a5f9157e4c0dce54a61e78787 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| module FoldTogether where | |
| import Prelude | |
| import Data.Foldable | |
| import Data.Array | |
| import Data.Array.NonEmpty as N | |
| import Control.Bind | |
| chunksOf_ n [] = [] | |
| chunksOf_ n xs = take n xs:chunksOf_ n (drop n xs) | |
| foldTogether xs = group xs >>= (N.toArray >>> chunksOf_ 2 >>> map sum) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment