Contents
esoMsf
Implementation of a
MiniStringFuck
interpreter.
1
2
3
| > const _input = '+'.repeat(65) + '.' + '+.'.repeat(25);
> esoMsf.msf(_input)
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| const esoMsf = {
msfIncr: (mem, lim) => (mem + 1) % lim,
msfEval: function(data, chr) {
if (chr === '+') data.mem = this.msfIncr(data.mem, 256);
else if (chr === '.') data.out += String.fromCharCode(data.mem);
},
msf: function(input) {
const data = { mem: 0, out: '' };
[...input].forEach(elt => this.msfEval(data, elt));
return data.out;
}
};
|
deadfish()
Implementation of a Deadfish
interpreter.
1
2
3
4
5
6
| > deadfish('iissso')
[ 0 ]
> deadfish('diissisdo')
[ 288 ]
> deadfish('iiisdoso')
[ 8, 64 ]
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| const deadfish = (p, v=0) => {
const out = [];
const reset = () => (v === 256 || v < 0) ? v = 0 : null;
const parse = {
'i': () => v++,
'd': () => v--,
's': () => v *= v,
'o': () => out.push(v)
};
const interpret = f => {
f(v);
reset();
};
for (const cmd of [...p].map(char => parse[char])) {
interpret(cmd);
}
return out;
};
|