Skip to content

Instantly share code, notes, and snippets.

Created April 1, 2019 09:57
What would you like to do?
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 {}
Copy link

let threeVector = Vector<Int>.init(size: 3, initialValue: 0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment