Cal

From Esolang
Jump to navigation Jump to search
This article is not detailed enough and needs to be expanded. Please help us by adding some more information.

Cal is a simple tool used for doing simple calculations automatically invented by User:A. A lot of the commands are based on emojis(in order to enhance readability and denseness(which was in turn influenced by TECO, Text Editor and COrrector)).

Syntax

A mathematical expression will be read depending on how the program counter moves. After that, the mathematical expression will be evaluated and outputted to the console.

In order to jump through multiple tags, a combination of going-tag commands can be used, as in this one, which goes through 3 tags:⏩⏩⏩

Command set

Command Result
- Subtraction or negation operator
Number A constant
Indicates a tag
Go left 1 tag
Go right 1 tag
🔁 Repeat code between this indicator and the matching tag the absolute value of the-current-value times as it resets the value to the previous result of operations (0 if no previous results available)
🚫 End the program

Examples

Calculate 2*5

2⏫--5🔁🚫

Calculate the square of 4

2⏫2⏫--4🔁🔁🚫

Return the absolute value of -5

-5⏫--1🔁🚫

Comments

--1⏩This is an example of a comment.⏫🚫

Go right 2 tags

This can be useful when someone wants to jump through nested loops.

--1⏩⏩--1⏫⏩⏩⏫🚫

Set the result to infinity (i.e. an infinite loop)

⏫--1⏪🚫

Calculate 3+2*4+3

2⏫--4🔁--3--3