Avatar
@omochimetaru % for i in range(17): public struct Array${i}<Element> { % for j in range(i): var element${j}: Element % end public init( % for j in range(i): % if j == i - 1: _ element${j}: Element % else: _ element${j}: Element, % end % end ) { % for j in range(i): self.element${j} = element${j} % end } public subscript(index: Int) -> Element { get { switch index { % for j in range(i): case ${j}: return element${j} % end default: preconditionFailure("Out of bounds: \(index)") } } set { switch index { % for j in range(i): case ${j}: element${j} = newValue % end default: preconditionFailure("Out of bounds: \(index)") } } } public var count: Int { return ${i} } } % end