Last active
June 24, 2016 09:37
-
-
Save InsertNetan/d74a85524a2e6e5f5c81fdf329ca1f9d 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
extension Array { | |
func scanl<T>(initial: T, combine:@noescape (Element, T) -> T) -> [T] { | |
guard let first = self.first else { return [initial] } | |
return [initial] + Array(self.dropFirst()).scanl(initial: combine(first, initial), combine: combine) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment