Created
February 7, 2021 22:15
-
-
Save justinmeiners/c5e0ca2227f3fb66eab3ba983f9b0862 to your computer and use it in GitHub Desktop.
This file contains 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
func foldBinary<T>(_ list: [T], operation: (T, T) -> T) -> T? { | |
if let initial = list.first { | |
return list.dropFirst().reduce(initial, operation) | |
} else { | |
return nil | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment