https://github.com/jbrosdevelopment/calc_lang
A programming language designed to look like math and be used like a calculator
https://github.com/jbrosdevelopment/calc_lang
calculaor calculation programming-language rust
Last synced: 6 months ago
JSON representation
A programming language designed to look like math and be used like a calculator
- Host: GitHub
- URL: https://github.com/jbrosdevelopment/calc_lang
- Owner: JBrosDevelopment
- Created: 2024-08-11T18:19:09.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-09-09T01:22:44.000Z (over 1 year ago)
- Last Synced: 2025-03-24T11:21:55.867Z (10 months ago)
- Topics: calculaor, calculation, programming-language, rust
- Language: Rust
- Homepage:
- Size: 72.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Calculator Language
This is a programming langauage that makes it extremely straightforward to program mathamatical expressions.
**Functions**
```
lerp(A, B, T) => A + T * (B - A)
display(lerp(0, 50, 100))
```
**Variables**
```
(5 * 60)^3 -> X
99 -> Y
XY -> Z
display(Z)
```
**Constants**
```
3.14159 -> pi
pi * 2 -> tau
```
**Comments**
```
... display alt character function
dac(120) ... '120' is the alt-code for 'x'
... displays 'x' to the console
```
**If Patterns**
```
... returns X if X > Y, else returns Y
max(X, Y) => X > Y: X; Y
max(-5, 70) -> A
7 * (5 > A: 1; 2) -> B
```
**Markers and `goto()`**
```
$0 ... marker
I + 1 -> I ... increment I
I < 10: goto(0) ... loops 10 times
```
**Complex Functions**
```
degtorad(X) => X * (pi / 180)
sin(X) => degtorad(X) - (degtorad(X)^3 / 3!) + (degtorad(X)^5 / 5!) - (degtorad(X)^7 / 7!)
cos(X) => 1 - (sin(X)^2)
tan(X) => sin(X) / cos(X)
ln(X) => 2 * ((X-1) / (X+1) + (1/3) * ((X-1)/(X+1))^3 + (1/5) * ((X-1)/(X+1))^5 + (1/7) * ((X-1)/(X+1))^7 + (1/9) * ((X-1)/(X+1))^9)
log(X) => ln(X) / ln(10)
```
**Sets**
```
{ 5, 6, sin(7), X } -> W
display(W_1) ... displays first index of set W '5'
```
**[Example Code](https://github.com/JBrosDevelopment/calc_lang/blob/master/src/calculation.txt)**