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
import simd | |
static func interpolate(desiredX: inout [Float], y: inout [Float]) -> [Float] { | |
let n = desiredX.count - 1 | |
let stride = vDSP_Stride(1) //Int Type Alias | |
let denominator = Float(n) / Float(y.count - 1) | |
let control: [Float] = desiredX.map { | |
let x = Float($0) / denominator | |
let smoothStep = Float(simd_smoothstep(0, 1, simd_fract(x))) |
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
import UIKit | |
import AVFoundation | |
//Dictionary string-> Dictionary | |
let dictionaryString = "{\ncode=0;\nphotoLink=\"\";\nplayerLastName=\"\";\nplayerName=\"\";\n}" | |
var arrayOfElements = dictionaryString.characters.split{$0 == "\n"}.map(String.init) | |
arrayOfElements.removeLast() |
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
import UIKit | |
import AVFoundation | |
//JSON String -> Dictionary | |
let jsonText = "{\"anotherKey\":\"anotherValue\",\"aKey\":\"aValue\"}" | |
var dictonary:NSDictionary? | |
if let data = jsonText.dataUsingEncoding(NSUTF8StringEncoding) { |
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
import UIKit | |
import AVFoundation | |
//Dictionary -> JSON String | |
let dictionary = ["aKey": "aValue", "anotherKey": "anotherValue"] | |
var theJSONText:String? | |
do { |
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
func winDetection() -> Bool { | |
//Check rows | |
for i in 0...2 { | |
if((board[3*i] == board[3*i + 1]) && (board[3*i] == board[3*i + 2]) && !(String(board[3*i]) == "EMPTY")){ | |
print("Someone won at row:") | |
print(i) | |
print( board[i]) | |
return true | |
} |