duplicates = multiple editions
A Classical Introduction to Modern Number Theory, Kenneth Ireland Michael Rosen
A Classical Introduction to Modern Number Theory, Kenneth Ireland Michael Rosen
// Given array of 2-tuples, return two arrays | |
func unzip<T, U>(array: [(T, U)]) -> ([T], [U]) { | |
var t = Array<T>() | |
var u = Array<U>() | |
for (a, b) in array { | |
t.append(a) | |
u.append(b) | |
} | |
return (t, u) | |
} |
// See: https://devforums.apple.com/message/1000934#1000934 | |
import Foundation | |
// Logic | |
operator prefix ¬ {} | |
@prefix func ¬ (value: Bool) -> Bool { | |
return !value | |
} |
// | |
// JAZMusician.h | |
// JazzyApp | |
// | |
#import <Foundation/Foundation.h> | |
/** | |
JAZMusician models, you guessed it... Jazz Musicians! | |
From Ellington to Marsalis, this class has you covered. |
struct MySet<KeyType : Hashable> : Sequence, ArrayLiteralConvertible | |
{ | |
var dictionaryOfItems = Dictionary<KeyType,Bool>() | |
typealias GeneratorType = MapSequenceGenerator<Dictionary<KeyType, Bool>.GeneratorType, KeyType> | |
init() {} | |
init(array: KeyType[]) { | |
for item in array { | |
self.dictionaryOfItems.updateValue(true, forKey: item) | |
} |
import Swift | |
struct SetGenerator<T : Hashable> : Generator { | |
var dictGenerator : DictionaryGenerator<T, Void> | |
init(_ d : Dictionary<T,Void>) { | |
dictGenerator = d.generate() | |
} | |
// | |
// Set | |
// | |
struct MySet<KeyType : Hashable> : Sequence | |
{ | |
var dictionaryOfItems = Dictionary<KeyType,Bool>() | |
init() {} | |
init(array:Array<KeyType>) { |
extension Array { | |
func first() -> Element? { | |
if isEmpty { | |
return nil | |
} | |
return self[0] | |
} | |
func last() -> Element? { |