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
enum Direction { | |
case north, east, south, west | |
var left: Direction { | |
switch self { | |
case .north: return .west | |
case .west: return .south | |
case .south: return .east | |
case .east: return .north | |
} |
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
// The contingency table contains the support counts for each item | |
// in comparision with one another. | |
struct ContingencyTable { | |
var bc: Int // B and C | |
var b_c: Int // B and not C | |
var _bc: Int // not B and C | |
var _b_c: Int // not B and not C | |
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
var accumulatedItemSets = Dictionary(uniqueKeysWithValues: database.map { | |
(Set([$0.key]), Set($0.value)) }) | |
var itemSetsToEvaluate = accumulatedItemSets | |
while !itemSetsToEvaluate.isEmpty { | |
var temp: [Set<String>: Set<Int>] = [:] | |
itemSetsToEvaluate.pairs().forEach { a, b in | |
let key = a.key.union(b.key) | |
let value = a.value.intersection(b.value) | |
if value.count >= absoluteSupport { |
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 Foundation | |
typealias Quality = Int | |
typealias SellIn = Int | |
typealias UpdateRule = (Item) -> Item | |
struct Item { | |
enum Kind: String { | |
case normal |
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
extension StoryboardInitializable where Self: UIViewController { | |
static var storyboardName: String { | |
return "Main" | |
} | |
static var storyboardBundle: Bundle? { | |
return nil | |
} | |
static var storyboardIdentifier: String { | |
return String(describing: self) |
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
struct BeginsWith { | |
let value: String | |
init(_ value: String) { | |
self.value = value | |
} | |
} | |
func ~=(pattern: BeginsWith, value: String) -> Bool { | |
return value.hasPrefix(pattern.value) | |
} |
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
/** | |
* Copyright (c) 2016 Razeware LLC | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is | |
* furnished to do so, subject to the following conditions: | |
* |
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
// | |
// Blurring.swift | |
// TransitionDemo | |
// | |
// Created by Ray Fix on 1/7/16. | |
// | |
import UIKit | |
protocol Blurring {} |
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
class Person {} | |
unowned var zombie: Person | |
do { | |
let alive = Person() | |
zombie = alive | |
} | |
// a zombie is born |
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
public enum LinkedList<T> { | |
case end | |
indirect case node(value: T, next: LinkedList) | |
public func cons(_ value: T) -> LinkedList { | |
return .node(value: value, next: self) | |
} | |
} |