Programming practice implemented in Swift
git clone https://github.com/matthewfaller/algorithm-practice
cd algorithm-practice/
swift test
A simple implementation of a classic structure
let list = LinkedList<String>()
list.append("Hello")
list.append("World!")
Conforms to the Sequence
Protocol
let numbers: LinkedList = [1, 2, 3, 4]
let factorial = numbers.reduce(1, *)
print(factorial)
24
Uses generics
struct User: Codable, Hashable {
let id: String
let name: String
}
let users: LinkedList = [
User(id: "1", name: "Emily Blunt"),
User(id: "2", name: "John Krasinski")
]
users.filter(isActor).forEach(updateUser)