Skip to content

Instantly share code, notes, and snippets.

View exyi's full-sized avatar

Standa Lukeš exyi

View GitHub Profile
@exyi
exyi / BF.ts
Created February 4, 2016 15:38
Brainfuck in ts
class Bf {
element: HTMLElement;
exec(script: string, input: string, inputPos = [0], pos = 0, data: number[] = [], ptr = [0]) {
while (script.length > pos) {
switch (script[pos]) {
case '+': data[ptr[0]] = ((data[ptr[0]] | 0) + 1) % 256;
break;
case '-': data[ptr[0]] = ((data[ptr[0]] | 0) - 1) % 256;
break;
case '<': ptr[0]--;