User talk:A

From Esolang
Jump to navigation Jump to search

Counting

So, should the instruction count be about how many "when" blocks it has passed?

Counting is a language whose only possible value is the instruction count and the accumulator. The instruction count increments after every line of execution (i.e. every non-skipped line) and start at 1. It cannot be assigned. (The counter is incremented every time before the execution of a line. The "when" lines aren't counted.)

The accumulator, initialized at 0, can only be added by the (potentially processed) instruction count. The accumulator cannot be subtracted or assigned by the instruction count. However, if there is input in the input buffer, the accumulator would be set to the integer specified at the input.

Even if none of the conditions are fullfilled, the language continues to execute without stopping.

Example (Infinite counter)

when cnt > 0
    out cnt

Range from 2 to 100.

when cnt > 100
    halt
when cnt > 2
    out cnt

Count up with a step of 2, starting with 2.

when cnt % 3 == 2
    acc += cnt
    out acc

Digital root calculator

when cnt - 1 == 1 + (acc - 1) % 9 
    out cnt - 1
    halt

Line-based cat program

when 1
    read acc
    out acc