Calcu-less 2
Calcu-less 2 is a language built around integrals. Programs are made up of nested integrals, with the bounds and functions as inputs, and the differential as the command instruction. The end result should be one giant integral that can be calculated to be one answer, but also does something else when using these commands.
Language Specification
Order of Operations
When executing Calcu-less 2 code, instructions are performed inside out like most functional languages. In larger programs the integrals will be in a sort of tree structure. If there are multiple integrals that could be executed, the upper bound of the most outside integral is executed first, then the function, then the lower bound.
In the below example, the instructions will be performed in the order: dw, di, dp, dc, dx, dr, do
\int_{ \int_{1}^{ \int_{0}^{1}1 \,dx }r \,dr }^{ \int_{ \int_{-1}^{0}1 \,dw }^{1}i \,di } \int_{0}^{ \int_{2}^{3}33 \,dp }c \,dc \,do
Loops
If a loop instruction (dl) is encountered, the number in the function input is compared to the one in the upper bound. If the two numbers are equal, the loop ends. If they aren't all nested integrals inside the function input of the loop integral are reset to what they were at the beginning of the program. Neither of the bounds are reset. The upper bound will generally be used for pre-loop commands, while the lower bound will be used for post-loop commands.
Fractions as Input
Since many basic integrals result in fractions as answers, fractions are allowed as input. For example, \int_{0}^{1/2}3/4\,dx
is a valid command. ASCII characters and memory addresses should be integers, fractions are not allowed in those contexts.
Commands
Listed below is every instruction in Calcu-less 2 as well as an example for how it would be written in a program.
Instruction | Result | Example |
---|---|---|
di | Reads a number from input and replaces i | \int_{0}^{1}i\,di
|
do | Prints the return value of the integral to output | \int_{1}^{5}3\,do
|
dc | Reads in an ASCII character from input and replaces c | \int_{0}^{1}c\,dc
|
dp | Prints the return value of the integral to output as an ASCII character | \int_{0}^{1}33\,dp
|
dr | Gets the value from the memory location in the upper bound and replaces r | \int_{0}^{1}r\,dr
|
dw | Writes the result of the integral to the memory location in the upper bound | \int_{-1}^{1}5\,dw
|
dx | Takes all inputs as number and calculates an integral | \int_{0}^{2}5\,dx
|
dl | Repeats nested integrals in the function location until result equals the upper bound | \int_{0}^{0}\int_{0}^{1}i\,di\,dl
|
Computational Class
Calcu-less 2 is Turing complete, and can be mapped to Brainfuck, as shown below.
Brainfuck | Calcu-less 2 |
---|---|
> | dr/dw can access any part of memory |
< | dr/dw can access any part of memory |
+ | \int_{-1}^{0}\int_{-1}^{\int_{-1}^{0}r\,dr}1\,dx\,dw
|
- | \int_{-1}^{0}\int_{1}^{\int_{-1}^{0}r\,dr}1\,dx\,dw
|
. | \int_{0}^{1}\int_{-1}^{0}r\,dr\,dp
|
, | \int_{-1}^{0}\int_{0}^{1}c\,dc\,dw
|
[ | dl can be used for loops |
] | dl can be used for loops |
Example Programs
Hello, World!
\int_{0}^{33/100} \int_{0}^{25/27} \int_{0}^{18/19} \int_{0}^{38/37} \int_{0}^{37/29} \int_{0}^{87/32} \int_{0}^{8/11} \int_{0}^{44/111} \int_{0}^{37/36} \int_{0}^{1} \int_{0}^{108/101} \int_{0}^{101/72} \int_{0}^{72}1 \,dp \,dp \,dp \,dp \,dp \,dp \,dp \,dp \,dp \,dp \,dp \,dp \,dp
Factorial
\int_{ \int_{0}^{1} \int_{0}^{1}r \,dr \,do }^{ \int_{0}^{0} \int_{-1}^{0} \int_{0}^{1} \int_{0}^{1}i \,di \,dw \,dw \,dx } \int_{2}^{ \int_{-1}^{0}r \,dr } \int_{0}^{1} \int_{0}^{ \int_{-1}^{0} \int_{1}^{ \int_{-1}^{0}r \,dr }1 \,dx \,dw } \int_{0}^{1}r \,dr \,dx \,dw \,dx \,dl
External References
- https://en.wikipedia.org/wiki/Integral (If you don't know what integrals are)
- https://latexeditor.lagrida.com/ (Useful website for making large integrals)