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 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() } | |
} |
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
#!/bin/sh | |
set -e | |
if [ -z "${SWIFTPM_CONFIGURATION}" ]; then | |
SWIFTPM_CONFIGURATION=.bootstrap/lib/swift/pm/4 | |
fi | |
if [ -z "${CONFIGURATION}" ]; then | |
CONFIGURATION=release |
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 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] |
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
// 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__; } |