You can run this program on any LMC emulator, such as http://peterhigginson.co.uk/LMC/
LMC, which stands for Little Man Computer is a model of a computer, used to teach students how CPUs work. Read More.
@interface UIView (MPAdditions) | |
@end | |
@implementation UIView (MPAdditions) | |
- (id)debugQuickLookObject { | |
if (self.bounds.size.width < 0.0f || self.bounds.size.height < 0.0f) { | |
return nil; | |
} | |
// Creating a generic recursive data structure with autoclosure. (READ ALL NOTES; THIS MAY NOT DO WHAT YOU WANT.) | |
// Closures are reference types, so the size is known (? I think ?) | |
// Note that this is just because of unimplemented features in the compiler in Beta5 | |
// There's no reason to think this is a long-term requirement. | |
// IMPORTANT: the closure will run every time you access this value, so if that has | |
// side effects, this won't work. It's only possible on pure value types. | |
// But the fact that this works as expected is actually kind of incredible. | |
// Think about what is required for it to work out the type for NestedList.Elem("first"). |
/// Sectional Sale | |
prefix operator >> {} | |
postfix operator >> {} | |
public prefix func >>(rhs: UInt16) -> UInt16 -> UInt16 { | |
return { lhs in lhs >> rhs } | |
} | |
public postfix func >>(lhs: UInt16) -> UInt16 -> UInt16 { |
function await(generatorFunction) { | |
let gen = generatorFunction(); | |
/** | |
* @param {any?} err The error to throw in the generator, where yield was last called. | |
* @param {any?} result The result to pass to the genarator for the last call to yield | |
*/ | |
function next(err, result) { | |
// If the last promise that was yielded was rejected, | |
// trigger an error inside the generator where yield was last called |
declare function require(module:string):any; | |
declare var process:any; | |
var readline = require('readline'); | |
var fs = require('fs'); | |
type brainfuckDone = (char : string) => void; | |
type brainfuckInput = (done : brainfuckDone) => void; | |
function brainfuck(tokens : string[], inp : brainfuckInput) { |
import Cocoa | |
protocol Thing { | |
var x: String {get} | |
init(s: String) | |
} | |
class Foo: Thing { | |
let x: String |
You can run this program on any LMC emulator, such as http://peterhigginson.co.uk/LMC/
LMC, which stands for Little Man Computer is a model of a computer, used to teach students how CPUs work. Read More.
extension String { | |
var composedCount : Int { | |
var count = 0 | |
enumerateSubstringsInRange(startIndex..<endIndex, options: .ByComposedCharacterSequences) {_ in count++} | |
return count | |
} | |
} |
@import Foundation; | |
@import CoreGraphics; | |
typedef struct __attribute__((objc_boxable)) CGPoint CGPoint; | |
typedef struct __attribute__((objc_boxable)) CGSize CGSize; | |
typedef struct __attribute__((objc_boxable)) CGRect CGRect; | |
typedef struct __attribute__((objc_boxable)) CGVector CGVector; | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { |
/// An operator is given by a list of arities, where each element indicates the number of | |
/// variables bound by the operator at that position and the length of the list determines the | |
/// number of variables the operator accepts. The full generalization of arity is called | |
/// the operator's "valence". | |
/// | |
/// For example, if I have a little calculator language with let-bindings, its operators | |
/// would look like this: | |
/// | |
/// | |
/// enum CalcOps : Operator { |