Giter Club home page Giter Club logo

calculator.rs's Introduction

Calculator.rs Logo

Calculator.rs

English | 简体中文

An simple command-line calculator program writen with Rust.

Features

  • Variable support
> a = 1
= 1
> a
= 1
  • Fraction support
> f1 = fraction(1, 2)
= (1 / 2)
> f1 + 1
= (3 / 2)
  • 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 = new Array([1, 2, 3])
= {
  v: [
    1, 2, 3, 
  ]
  ...
}
> arr.push(4)
> arr
= {
  v: [
    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 = cl {age $Numb, name $Str}
= {
  age: Number
  name: String
}
> inst = new Person(10, "test") 
= {
  age: 10
  name: "test"
}

Installation

Windows || GNU/Linux || MacOS (x86_64)

Please go to the release page and download the latest released appropriate executable file,

Then just execuse it.

Other OS && Platform

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: Tutorials

calculator.rs's People

Contributors

bhznjns avatar bluemangoo avatar shenjackyuanjie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

calculator.rs's Issues

Feature request: 惰性表达式重定义(语法糖)

举个例子:

> a = 10
= 10
> b = 20
= 20
> sum = {a + b}
= <Lazy-Expression>
> sum()
= 30
> a += 1
= 11
> sum()
= 31
> sumPlusOne = sum + 1
= <Lazy-Expression>
> sumPlusOne()
= 32
> sum()
= 31
> sum += 2
= <Lazy-Expression>
> sum()
= 33

解释一下:

对惰性表达式进行操作,结果可以等同于重新定义了一个惰性表达式,比如下面两种是等价的:

lazyExpression + 1
{ lazyExpression() +1 }

当然你的实现也可以是把原先的惰性表达式拆包处理。

方程支持

可否加入方程支持?据我所知,目前大部分的方程都已经可以用公式法解决。那可否直接增加一个方程数据类型,然后将解方程的函数作为它的一个属性去用,或者通过一个命令来求方程类型的解来做到对解方程的支持,从而将这个语言作为一个高级的科学计算器使用?

Bug: 检测ansi支持

有些控制台不支持ansi,你需要在不支持的时候把它禁用了。

如果你不想这样的话:

Calculator.rs 1.8.4
> 1 + 1
= �[0;93m2�[0m
>

what you need:

 match enable_ansi_support::enable_ansi_support(){
    OK()=>{//code with ansi},
    Err()=>{//code without ansi}
}

二进制文件

考虑一下发布Linux平台的可执行二进制文件?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.