Moved to
This file contains hidden or 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
function Bindable(proto: any, name: PropertyKey) { | |
const desc = Object.getOwnPropertyDescriptor(proto, name) | |
delete proto.name | |
if ((proto['_dispatchEvent']) == undefined) { | |
Object.defineProperty(proto, '_dispatchEvent', { | |
value(event: Event) { | |
} |
This file contains hidden or 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
// x, y :: {0,1} | |
var and = (x,y) => x * y, | |
not = (x) => 1 - x, | |
or = (x,y) => 1 - (1 - x) * (1 - y) | |
and(0,0) // 0 | |
and(0,1) // 0 | |
and(1,0) // 0 | |
and(1,1) // 1 |
This file contains hidden or 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
- The application is currently single threaded | |
- The following commands have been implemented: | |
- exit | |
- create <PATH> | |
- open <PATH> | |
- display | |
- ls | |
- cd <TFS> (partial) | |
- mkdir <TFS> (partial). currently buggy due to nibble manipulation | |
- import <PATH> <TFS> (partial) stub + error checking only |
This file contains hidden or 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
function main() { | |
console.log("question1(0) == 0"); | |
console.assert(question1(0) == 0, `${question1(0)}`); | |
console.log("question1(1) == 1"); | |
console.assert(question1(1) == 1, `${question1(1)}`); | |
console.log("question1(7) == 13"); | |
console.assert(question1(7) == 13, `${question1(7)}`); | |
console.log("question1(12) == 144"); | |
console.assert(question1(12) == 144, `${question1(12)}`); |
This file contains hidden or 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
abstract class Observer { | |
abstract update(data?: any): void | |
} | |
abstract class Observable { | |
protected _observers: Observer[] = [] | |
observe(observer: Observer) { | |
if (this._observers.indexOf(observer) > -1) | |
throw new Error('Observer already added') |
This file contains hidden or 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
abstract class Command { | |
abstract execute(): void | |
} | |
abstract class UndoableCommand extends Command { | |
abstract undo(): void | |
} | |
class Direction { | |
static readonly UP = 0 |
This file contains hidden or 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
abstract class Comparable { | |
abstract le(other: this): boolean | |
min(other: this): Comparable { | |
return this.le(other) ? this : other | |
} | |
} | |
abstract class Ring { | |
constructor( | |
readonly zero: Ring, |
This file contains hidden or 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
interface Publisher<T> { | |
subscribe(s: Subscriber<T>): void | |
} | |
interface Subscriber<T> { | |
onNext(value: T): void | |
onError(e: Error): void | |
onDone(): void | |
onSubscribe(s: Subscription): void | |
} |
This file contains hidden or 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
// data Either a b = Left a | Right b | |
abstract class Either<A, B> { | |
constructor(public value: A | B) { } | |
} | |
// Inject Left | |
// inl a | |
class Left<A> extends Either<A, never>{ | |
constructor(value: A) { super(value) } | |
} | |
// Inject Right |