protocol Context { var itemsCount: Float { get } } protocol Position { var x: Float { get } var y: Float { get } } func memoryGap() -> Float { return memorySide() + memorySpace() } func memoryGroups(c: Context) -> Record { var items: Record = {}; // @ts-ignore let ids = utsIndexArray(c.itemsCount); ids.forEach { i in // @ts-ignore items[i] = utsFloor(Float(i) / 2) } return items; } func memorySide() -> Float { return 50 } func memorySpace() -> Float { return 20 } func memoryItemPositions(c: Context) -> [Position] { var pos: [Position] = [] // @ts-ignore let ids = utsIndexArray(c.itemsCount); ids.forEach { i in // @ts-ignore let row = utsFloor(Float(i) / 4) let x = memoryGap() + (Float(i) - row * 4) * memoryGap() let y = memoryGap() + row * memoryGap() // @ts-ignore pos.append(memoryCreatePosition(x, y)) } return pos }