Flowchart

From Esolang
Jump to navigation Jump to search

Flowchart is an esolang created by User:Aadenboy directly based on flowcharts.

Structure

Flowchart works on a 2D space, with actions connected by lines. Programs start on the first ( ) node, of which is the top-most left-most node. Flowchart allows for multiple program pointers to run in parallel, order going from top-most left-most, traveling right, then downwards. Program halts once all pointers halt. When a pointer re-enters a node or path it's been through before, it will go in the direction that it had previously traveled unless it were to turn it 180º.

The memory of Flowchart works on a tape of infinite deques, and a single register for each pointer, each holding bits (0 and 1). A pointer's register is independent to it and can hold a single bit, however all pointers share the same stacks.

The ( ) node is the only node that allows splitting.

Node Name Description
( ) Start/Fork/No-op/End A multi-functional node. If there are multiple paths, it will create new pointers for each path.
[ ] Toggle Toggles the value currently in the register. If it is empty, it's set to 1.
{ } Clear Clears the value currently in the register, making it empty.
< > Switch A switch. Reads from the register. If it is 0, the pointer takes the path to the right. If it is 1, the pointer takes the path to the left. If it is empty, the pointer continues forward.
/ / Input Read a single bit from input, storing it in the register. This is empty if there are no more bits to read.
\ \ Output Output a single bit from the register.
\[ ]/ Push top Clear the register, and push its value to the top of the currently selected deque.
/[ ]\ Push bottom Clear the register, and push its value to the bottom of the currently selected deque.
\{ }/ Pop top Clear the register, and pop the top of the currently selected deque to the register.
/{ }\ Pop bottom Clear the register, and pop from the bottom of the currently selected deque to the register.
< ] Switch left Change the currently selected deque to the one previous to it.
[ > Switch right Change the currently selected deque to the one after it.

Examples

Truth machine

     ( )──┐        
         / /       
          │        
( )─\ \──< >┬─\ \─┐
            │     │
            └─────┘

Cat program

( )──┐   
  ┌─/ /─┐
  │  │  │
  │\[ ]/│
  │  │  │
  └─< >─┘
     │   
  ┌/{ }\┐
  │  │  │
  │ \ \ │
  │  │  │
  └─< >─┘
     │   
    ( )