Functional Tetris implementation in Swift