Skip to content

A simple command-line calculator program writen with Rust.

License

Notifications You must be signed in to change notification settings

BHznJNs/Calculator.rs

Repository files navigation

Calculator.rs

English | 简体中文

An simple command-line calculator program writen with Rust.

Features

  • Variable support
> a = 1
= 1
> a
= 1
  • Math functions support
> Math.sin(1) 
= 0.84147098
  • Lazy-Expression support
> a = 10
= 10
> b = 20
= 20
> sum = {a + b}
= <Lazy-Expression>
> sum()
= 30
> a += 1
= 11
> sum()
= 31
  • Comment support
> 1 + 1 # plus
= 2
  • Array support
> arr = [1, 2, 3] 
= [
  1, 2, 3,
]
> push(arr, 4) 
> arr
= [
  1, 2, 3, 4,
]
>
  • Function defining support
> plus1 = fn(i $Numb) {i + 1} 
> plus1(1) 
= 2
  • Script execute support
calculator.exe script
  • OOP support
> Person = cls {age $Numb, name $Str}
= {
  name,
  age,
}
> inst = new Person(10, "test") 
= {
  age: 10
  name: test
}

Installation

Windows

Go to the release page and download the latest released .exe file

Then just execuse it.

Other OS

You need to install the Rust (version >= 1.60).

Clone this repository

git clone https://github.com/BHznJNs/Calculator.rs
cd Calculator.rs

Then, use Cargo to compile

cargo build --release

The release executable file will be at: Calculator.rs/target/release

Tutorial

See here: Syntax Tutorial