Skip to content

Instantly share code, notes, and snippets.

@dmwit
Created November 15, 2019 18:18
Show Gist options
  • Save dmwit/6dce178eab1988fc7219153534ad8788 to your computer and use it in GitHub Desktop.
Save dmwit/6dce178eab1988fc7219153534ad8788 to your computer and use it in GitHub Desktop.
from Dmwit.hs
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