Created
November 3, 2018 02:03
-
-
Save dmwit/81d5f8e99612847a7611a66895863eb8 to your computer and use it in GitHub Desktop.
treefold
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
foldb1 op = foldb' where | |
pairwise (x:y:rest) = op x y : pairwise rest | |
pairwise shortList = shortList | |
foldb' xs@(_:_:_) = foldb' (pairwise xs) | |
foldb' [x] = x | |
foldb op def xs = foldb1 op (def:xs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment