Created
July 10, 2014 23:05
-
-
Save owensd/e500384b63713aa88bb1 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
extension Array { | |
func first() -> T { | |
return self[0] | |
} | |
func last() -> T { | |
return self[self.count - 1] | |
} | |
} | |
func reverse<T>(items: [T]) -> [T] { | |
if items.count == 0 { | |
return [T]() | |
} | |
return reverse(items[1..<items.count]) + [items.first()] | |
} | |
let items = [1, 2, 3] | |
reverse(items) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment