Skip to content

Instantly share code, notes, and snippets.

View lukewakeford's full-sized avatar
🚲
Cycling

Luke Wakeford lukewakeford

🚲
Cycling
View GitHub Profile
@lukewakeford
lukewakeford / Reduce Playground Example
Last active January 8, 2019 14:29
Reduce Playground Example
import UIKit
struct product {
var price:Int?
var name:String
}
let array = [
product(price: 100, name: "First"),
product(price: nil, name: "Second"),
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
cell.rankLabel.isHidden = true
if let rank = list.rank {
cell.rankLabel.setTitle(title: rank, titleFont: UIFont.customBold!, colour: .white)
cell.rankLabel.isHidden = false
}
}
func sortConvex(input: [CLLocationCoordinate2D]) -> [CLLocationCoordinate2D] {
// X = longitude
// Y = latitudeß
// 2D cross product of OA and OB vectors, i.e. z-component of their 3D cross product.
// Returns a positive value, if OAB makes a counter-clockwise turn,
// negative for clockwise turn, and zero if the points are collinear.
func cross(P: CLLocationCoordinate2D, A: CLLocationCoordinate2D, B: CLLocationCoordinate2D) -> Double {
let part1 = (A.longitude - P.longitude) * (B.latitude - P.latitude)