Created
March 27, 2024 19:38
-
-
Save ldct/c5ebb23a074ebc7dd9a56fc8ad309f24 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
func sum(a: Int?, b: Int?) -> Int? { | |
a.flatMap({ unwrappedA in | |
b.flatMap({ unwrappedB in | |
.some(unwrappedA + unwrappedB) | |
}) | |
}) | |
} | |
func sum(_ a: [Int], _ b: [Int]) -> [Int] { | |
a.flatMap({ unwrappedA in | |
b.flatMap({ unwrappedB in | |
[unwrappedA + unwrappedB] | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment