Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Execute-Brain-/Mathematica/execute-brain--1.math
Normal file
21
Task/Execute-Brain-/Mathematica/execute-brain--1.math
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
bf[program_, input_] :=
|
||||
Module[{p = Characters[program], pp = 0, m, mp = 0, bc = 0,
|
||||
instr = StringToStream[input]},
|
||||
m[_] = 0;
|
||||
While[pp < Length@p,
|
||||
pp++;
|
||||
Switch[p[[pp]],
|
||||
">", mp++,
|
||||
"<", mp--,
|
||||
"+", m[mp]++,
|
||||
"-", m[mp]--,
|
||||
".", BinaryWrite["stdout", m[mp]],
|
||||
",", m[mp] = BinaryRead[instr],
|
||||
"[", If[m[mp] == 0,
|
||||
bc = 1;
|
||||
While[bc > 0, pp++; Switch[p[[pp]], "[", bc++, "]", bc--]]],
|
||||
"]", If[m[mp] != 0,
|
||||
bc = -1;
|
||||
While[bc < 0, pp--; Switch[p[[pp]], "[", bc++, "]", bc--]]]]];
|
||||
Close[instr];];
|
||||
bf[program_] := bf[program, ""]
|
||||
2
Task/Execute-Brain-/Mathematica/execute-brain--2.math
Normal file
2
Task/Execute-Brain-/Mathematica/execute-brain--2.math
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
bf["++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.
|
||||
<<+++++++++++++++.>.+++.------.--------.>+.>."]
|
||||
Loading…
Add table
Add a link
Reference in a new issue