1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 18:23:44 +03:00

Matrix is a functor.

This commit is contained in:
Rob Rix 2015-10-05 17:18:40 -04:00
parent 0e8b74e830
commit 3fdda99653

View File

@ -23,6 +23,13 @@ struct Matrix<A> {
} }
// MARK: Functor
func map<Other>(transform: A -> Other) -> Matrix<Other> {
return Matrix<Other>(width: width, height: height, values: values.map { $0.map(transform) })
}
// MARK: Implementation details // MARK: Implementation details
private init(width: Int, height: Int, values: [Memo<A>]) { private init(width: Int, height: Int, values: [Memo<A>]) {