a-gram

From Esolang
Jump to: navigation, search
This language (or library, or other thing) is a Work-in-progress

a-gram is an esoteric programming language that only uses Unicode characters with "gram" in the name.

Syntax

Basic commands

Command Description
(LESSER YIN) Grabs a single character from console and puts it on the stack
(GREATER YANG) Outputs the value on the top of the stack as a character
(LESSER YANG) Outputs the value on the top of the stack as a number
(DECREASE) Lowers the value on the top of the stack
(INCREASE) Increases the value on the top of the stack
(HEAVEN) Puts 1 on the top of the stack
(THE CREATIVE HEAVEN) Puts 127 on the top of the stack
(THE WELL) Pushes a random number between 0 and 127 to top of the stack
(ENTHUSIASM) Squares value on the top of the stack
(ABUNDANCE) Duplicates the value on the top of the stack
(RETREAT) Pushes the value on the bottom of the stack to the top of the stack

Note that if nothing is on the stack, using INCREASE and DECREASE will return with an error message.

Flow control

a-gram allows you to loop based on certain conditions. You may start a loop by using the DURATION hexagram, . There are multiple conditions on which to loop based on. These are placed directly after the DURATION hexagram.

Condition Description
(INNER TRUTH) Loops while the current value on the stack is truthy (greater than 0)
(DISPERSION) Loops while the stack has values in it
(COMING TO MEET) Pops a value off the stack and then loops until the value currently on the stack is equal to the popped value
(SMALL PREPONDERANCE) Pops a value off the stack and then loops until the value currently on the stack is less than the popped value
(GREAT PREPONDERANCE) Pops a value off the stack and then loops until the value currently on the stack is greater than the popped value
(WAITING) Loops infinitely

The loop then must have a hexagram for BEFORE COMPLETION (䷿) to start the loop block, as well as a hexagram for AFTER COMPLETION () to end it.

For example, here is a simple yes-like program, along with an explanation of how it works.

⚍䷟䷄䷿䷶⚌䷾
⚍ Grab single character from STDIN
䷟ ䷄ Loop forever
䷿   {
  ䷶   Duplicate value on stack
  ⚌   Pop value off stack and print it
䷾   }

As well, there is one additional flow-control related command: RETURN (). This command jumps to the start of any loop it is in. If it is not in a loop, it will instead jump to the start of the file, making infinite loops that surround the entire program easier.

Example programs

Hello, world!

☰䷩䷩䷩䷩䷩䷩䷩䷏䷩䷩䷩䷩䷩䷩䷩䷩⚌
䷀䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷶⚌
䷩䷩䷩䷩䷩䷩䷩䷶⚌ 
䷶⚌
䷩䷩䷩⚌
☰䷩䷩䷩䷩䷩䷩䷏䷨䷨䷨䷨䷨⚌
☰䷩䷩䷩䷩䷩䷏䷨䷨䷨䷨⚌
䷀䷨䷨䷨䷨䷨䷨䷨䷨䷶⚌
䷨䷨䷨䷨䷨䷨䷨䷨䷶⚌
䷩䷩䷩䷶⚌
䷨䷨䷨䷨䷨䷨䷶⚌
䷨䷨䷨䷨䷨䷨䷨䷨⚌
☰䷩䷩䷩䷩䷩䷏䷨䷨䷨⚌
☰䷩䷩䷩䷩䷩䷩䷩䷩䷩⚌

This outputs "Hello, world!" with a trailing newline.

Echo program

䷟䷄䷿⚏䷟䷺䷿䷠⚌䷾䷾

This fairly short program loops infinitely, echoing anything it receives from STDIN to STDOUT.

Implementations