Execute Brain****/J: Difference between revisions
m
Fixed syntax highlighting.
m (update for j804) |
m (Fixed syntax highlighting.) |
||
Line 1:
<
NB. operations
Line 63:
run=: [: flush step^:(pc < #@[)^:_
execute=: 2 }. compile@] run 0 0,0: :[</
Here is hello world:
<
+++++ +++++ initialize counter (cell #0) to 10
[ use loop to set the next four cells to 70/100/30/10
Line 89:
> + . print '!'
> . print '\n'
)</
Example use:
<
Hello World!
0 87 100 33 10</
execute compiles the program, generates an initial state of a blank tape with the data and instruction pointers both being zero, runs the program and then returns as its result the final state of the tape.
Line 103:
Or, here is the addDigit program from wikipedia, with explicit compilation and run as separate operations:
<
23
5
0 30 53 0</
Here, 2 and 3 were provided as input, and 5 was displayed as the result.
Line 119:
When investigating a bug, you can use:
<
This means that programs when run (or traced) will display each tape state after it has been generated, which means that when the program crashes you will have displayed a tape state shortly before the crash.
|