Clockwise

From Esolang
Jump to navigation Jump to search

Clockwise is a two-dimensional esolang by User:PythonshellDebugwindow where the only turns are 90° clockwise.

Syntax

Clockwise code is two-dimensional. It uses an instruction pointer (IP), which can point north, east, south, or west, to keep track of the current position in the code; it starts out in the northwesternmost corner facing east. If the IP ever returns to the northwesternmost character, the program halts. Each character is one command.

Memory

Clockwise uses an unbounded signed accumulator, initialized to zero.

I/O format

Input is pushed bit-by-bit to an input queue at the start of the program. The MSB is pushed first. Output must be pushed bit-by-bit to an output queue. Once 7 bits have been pushed, they are output as an ASCII character, whose MSB is the first bit pushed, and the queue is emptied.

Commands

Command Effect
R Rotate the IP 90° clockwise
? If the accumulator is not 0, rotate the IP 90° clockwise, else do nothing
! If the accumulator is 0, rotate the IP 90° clockwise, else do nothing
+ Increment the accumulator
- Decrement the accumulator
. Dequeue a bit from the input queue, set the LSB of the accumulator to the bit, and enqueue the bit back to the input queue
; Push the LSB of the accumulator to the output queue
S Set the accumulator to zero
(space) Nop

Examples

Hello World

+;-;;+;-;;;+;;-;;+;-;+;;;-;+;;-;;R
                                 +
                                 ;
                                 ;
                                 -
                                 ;
                                 +
                                 ;
                                 ;
                                 -
;                                ;
;                                ;
-                                +
;                                ;
+                                ;
;                                -
;                                ;
-                                +
;                                ;
;                                ;
+                                ;
;                                ;
;                                -
-                                ;
;                                +
;                                ;
+                                -
;                                ;
-                                ;
;                                ;
;                                ;
+                                ;
R ;-;+;;-;;;;;;;+;-;;;;;+;-;+;-;+R

Truth-machine

+-?.;.;.;.;.;.;.;?R
  R              R
R                 R

Cat program

+-?++.;R
  R    R

Implementations

A Python interpreter by User:Bangyen.