283
edits
KalmanKeri (talk | contribs) |
KalmanKeri (talk | contribs) |
||
| Line 28: | Line 28: | ||
* <code>p | q</code> forks the execution of the program so that one branch runs <code>p</code>, another branch runs <code>q</code>, sharing the same input and output stream. | * <code>p | q</code> forks the execution of the program so that one branch runs <code>p</code>, another branch runs <code>q</code>, sharing the same input and output stream. | ||
Start writing a routine that copies a natural number from the input to the output. | Start by writing a routine that copies a natural number from the input to the output. | ||
passNat = match 1; write 1; run passNat | match end; write end | passNat = match 1; write 1; run passNat | match end; write end | ||
| Line 37: | Line 37: | ||
The program terminates after matching and writing out the second <code>end</code> symbol. It skips the first <code>end</code> that terminates the first number and copies everything else. | The program terminates after matching and writing out the second <code>end</code> symbol. It skips the first <code>end</code> that terminates the first number and copies everything else. | ||
Effectively it concatenates two | Effectively it concatenates two sequences of <code>1</code>s. If any other symbol occurs in the input stream, the program fails. | ||
This language is obviously too weak. We can write simple filters, but we can't even check the equality of two numbers. In order to do it, we need a method that allows the first number to be accumulated and read back symbol by symbol as we read the second number. | This language is obviously too weak. We can write simple filters, but we can't even check the equality of two numbers. In order to do it, we need a method that allows the first number to be accumulated and read back symbol by symbol as we read the second number. | ||
edits