This project is an experimental cross between a stack-based language like Forth and an array-based language like APL.
Array-based languages like APL typically make heavy use of infix operators. This project gives a user the ability to write APL-like code in a reverse-polish notation which can make it easier to express a program from left to right.
One goal in this project is to demonstrate writing Rust in a pure functional style with functional-but-in-place mutation facilitated by the ownership system.
cargo run
- this will open a prompt where you can write a series of numbers and "words" that will be executed after hitting enter. The output will be "the stack" after executing the line. Enter a blank line to exit.
> 1 2 +
3
> 1 2 3
3
2
1
> 1 2 3 |
[[1.0, 2.0, 3.0,]]
> 1 2 3 | 5
5
[[1.0, 2.0, 3.0]]
> 1 2 3 | 5 *
[[5.0, 10.0, 15.0]]
> 1 2 3 | 5 * sum
30
+
Addition-
Subtraction*
Multiplication/
Division|
Create array from scalers at the top of the stacknegate
,neg
Negatereverse
,rev
Reverse arraylength
,len
Length of arraysum
Sum of arrayproduct
,prod
Product of arrayiota
Produce array that is a range from 1 to nright
Copy first element on the stackleft
Copy second element on the stackcommute
Swap the first and second element on the stack
- Refactor
- Booleans
- 2 Dimensions
- Higher order operators
- Custom words (functions)
- File interpreter