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
% swiftc -Xllvm -help-hidden /tmp/foo.swift | |
USAGE: swift (LLVM option parsing) [options] | |
OPTIONS: | |
-a9-754319-workaround - Enable workarounds for A9 HW bugs #754319 | |
-a9-754320-workaround - Enable workarounds for A9 HW bugs #754320 | |
-aarch64-use-tbi - Assume that top byte of an address is ignored | |
-agg-antidep-debugdiv=<int> - Debug control for aggressive anti-dep breaker | |
-agg-antidep-debugmod=<int> - Debug control for aggressive anti-dep breaker | |
-aggressive-ext-opt - Aggressive extension optimization |
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 | |
struct Test { | |
var value: Int = 0 | |
var f: (Int, Int) -> Int { | |
mutating get { | |
var this = self | |
print("in getter value: \(this.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
import Foundation | |
func copy<T: AnyObject>(obj: T) -> T { | |
let ptr = UnsafeMutablePointer<T>.alloc(1) | |
ptr.initialize(obj) | |
return ptr.memory | |
} | |
class C: NonObjectiveCBase { |
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
infix operator ??= { | |
associativity right | |
precedence 90 | |
assignment | |
} | |
func ??=<T>(inout optional: T?, @autoclosure defaultValue: () -> T?) { | |
optional = optional ?? defaultValue() | |
} |
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
protocol Copyable: class { | |
init(copy: Self) | |
} | |
// | |
// this is a 'diffing' constructor, in your callback modify properties of $0 as needed | |
// | |
func _copy<T:Copyable, U>(obj: T, @noescape fun: inout T -> ()) -> U { |
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 Cocoa | |
enum CoroutineState { | |
case Fresh, Running, Blocked, Canceled, Done | |
} | |
struct CoroutineCancellation: ErrorType {} | |
class CoroutineImpl<InputType, YieldType> { | |
let body: (yield: YieldType throws -> InputType) throws -> Void |
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 responderForType<T>(from: UIResponder) -> T? { | |
var current = from | |
while let next = current.nextResponder() { | |
if let result = next as? T { return result } | |
current = next | |
} | |
return nil | |
} |
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
""" | |
Exercises for the Markov Chain Monte-Carlo (MCMC) course available at | |
http://users.aims.ac.za/~ioana/ | |
""" | |
import numpy as np | |
import numpy.linalg as la | |
import pylab | |
from scipy import stats |
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 encode<T>(var value: T) -> NSData { | |
return withUnsafePointer(&value) { p in | |
NSData(bytes: p, length: sizeofValue(value)) | |
} | |
} | |
func decode<T>(data: NSData) -> T { | |
let pointer = UnsafeMutablePointer<T>.alloc(sizeof(T.Type)) | |
data.getBytes(pointer) | |
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 Expr { | |
case Lit(Int) | |
indirect case Neg(Expr) | |
indirect case Add(Expr,Expr) | |
indirect case Mul(Expr,Expr) | |
indirect case Sub(Expr,Expr) | |
} | |
let spaces = many(oneof(" \n\r")) | |
func token<P: ParserType>(p: P) -> Parser<P.A> { |