Skip to content

Instantly share code, notes, and snippets.

@CodaFi
CodaFi / turing-fake.swift
Last active November 25, 2021 00:50 — forked from garrigue/turing.ml
struct State0 {}; struct State1 {}; struct FinalState {} /*States*/
struct Symbol {}; struct Blank {} /*Symbols*/
struct Left {}; struct Right {} /*Directions*/
struct EndOfTape {} /*End of Tape*/
struct Transition<StartState, StartHead, EndState, EndHead, Direction> {
static func transitionOne() -> Transition<State0, Blank, State1, Symbol, Left> { fatalError() }
static func transitionTwo() -> Transition<State1, Blank, State0, Symbol, Right> { fatalError() }
static func transitionThree<State>() -> Transition<State, Symbol, FinalState, Symbol, Left> { fatalError() }
}
@CodaFi
CodaFi / update-swift-dev
Last active February 13, 2018 15:46 — forked from ddunbar/update-swift-dev
This is the script I currently use on OS X to get a working "swift-dev.xctoolchain" out of a built Swift. It isn't designed to work for anyone but me, but it should be easy to adapt. I always run this after every build, and then use `TOOLCHAINS=swift-dev swift build` (etc) to use the development compiler.
#!/bin/sh
set -e
if [ -z "${SWIFTPM_CONFIGURATION}" ]; then
SWIFTPM_CONFIGURATION=.bootstrap/lib/swift/pm/4
fi
if [ -z "${CONFIGURATION}" ]; then
CONFIGURATION=release
@CodaFi
CodaFi / bug.swift
Last active August 29, 2015 14:04 — forked from rbrockerhoff/bug.swift
extension Array {
mutating func merge <S: SequenceType where S.Generator.Element == Element> (seq: S) {
var gen = seq.generate()
while let (key : Element, value : Element) = gen.next() {
self[0] = value
}
}
}
var arr = [0]
@CodaFi
CodaFi / lambda.m
Last active August 29, 2015 13:57
// cc lambda.m -o lambda -framework Foundation -fobjc-arc && ./lambda
#import <Foundation/Foundation.h>
// use it like lambda(…args…)(…return value…)
#define lambda(...) \
^ (__VA_ARGS__) _lambda_body
#define _lambda_body(...) \
{ return __VA_ARGS__; }