Created
August 9, 2015 12:49
-
-
Save hachinobu/091257ddf24bfaf95936 to your computer and use it in GitHub Desktop.
Swift map
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 map<T, U>(xs: [T], f: T -> U) -> [U] { | |
var result: [U] = [] | |
for x in xs { | |
result.append(f(x)) | |
} | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment