Created
April 1, 2019 09:57
-
-
Save BasThomas/559f453d16c07f679e1022110a6fc608 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
struct Vector<T> { | |
let size: Int | |
let initialValue: T | |
struct Position: Equatable { | |
let row: Int | |
let column: Int | |
} | |
typealias Matrix = [Position] | |
let matrix: Matrix | |
init(size: Int, initialValue: T) { | |
self.size = size | |
self.initialValue = initialValue | |
var _matrix: Matrix = [] | |
for row in 0..<size { | |
for column in 0..<size { | |
_matrix.append(.init(row: row, column: column)) | |
} | |
} | |
self.matrix = _matrix | |
} | |
} | |
extension Vector: Equatable where T: Equatable {} |
Author
BasThomas
commented
Apr 1, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment