Skip to content

Instantly share code, notes, and snippets.

@InsertNetan
Created June 25, 2016 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save InsertNetan/9d9cee6c8759c0872836ac0151cf625d to your computer and use it in GitHub Desktop.
Save InsertNetan/9d9cee6c8759c0872836ac0151cf625d to your computer and use it in GitHub Desktop.
// same as scanl but without initial
extension Array {
func scanl(combine: (Element, Element) -> Element) -> [Element] {
guard let first = self.first else { return [] }
return Array(self.dropFirst()).scanl(initial:first, combine:combine)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment