Skip to content

Instantly share code, notes, and snippets.

@davidallsopp
Created June 24, 2015 21:59
Show Gist options
  • Save davidallsopp/c26a44342586a0b04e19 to your computer and use it in GitHub Desktop.
Save davidallsopp/c26a44342586a0b04e19 to your computer and use it in GitHub Desktop.
dropEach - not original, probably taken from Stack Overflow somewhere. Returns all lists generated by removing one element from the input
Prelude> import Data.List
Prelude Data.List> let dropEach xs = zipWith (++) (inits xs)(tail $ tails xs)
Prelude Data.List> dropEach [1,2,3,4,5]
[[2,3,4,5],[1,3,4,5],[1,2,4,5],[1,2,3,5],[1,2,3,4]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment