#calculator #repl #bc #cli

app eva

类似于bc(1)的Calculator REPL

9个版本

0.3.1 2022年11月8日
0.3.0 2022年10月21日
0.3.0-alpha.12022年7月5日
0.2.7 2019年11月7日
0.2.3 2019年3月31日

#171 in 数学

Download history 25/week @ 2024-03-11 5/week @ 2024-03-18 10/week @ 2024-03-25 64/week @ 2024-04-01 20/week @ 2024-04-08 7/week @ 2024-04-15 23/week @ 2024-04-22 7/week @ 2024-04-29 62/week @ 2024-05-06 5/week @ 2024-05-13 24/week @ 2024-05-20 14/week @ 2024-05-27 35/week @ 2024-06-03 29/week @ 2024-06-10 23/week @ 2024-06-17 40/week @ 2024-06-24

每月 129 次下载

MIT 协议

45KB
1K SLoC

heroimg.png

eva

简单的计算器REPL,类似于 bc(1),具有语法高亮和持久历史记录

eva.png

安装

  • Homebrew
$ brew install eva
  • crates.io
$ cargo install eva
  • 手动
$ git clone https://github.com/nerdypepper/eva.git
$ cargo run

用法

eva 0.3.1
NerdyPepper <[email protected]>
Calculator REPL similar to bc(1)

USAGE:
    eva [OPTIONS] [INPUT]

ARGS:
    <INPUT>    Optional expression string to run eva in command mode

OPTIONS:
    -b, --base <RADIX>    Radix of calculation output (1 - 36) [default: 10]
    -f, --fix <FIX>       Number of decimal places in output (1 - 64) [default: 10]
    -h, --help            Print help information
    -r, --radian          Use radian mode
    -V, --version         Print version information

输入表达式并按回车键,重复。

> 1 + sin(30)
1.5
> floor(sqrt(3^2 + 5^2))
5
> 5sin(45) + cos(0)
4.53553

更新

  • crates.io
$ cargo install eva --force
  • 手动
$ cargo install --force --path /path/to/eva

运算符

  • 二元运算符:+ - * / ^ **
  • 一元运算符:+ -

常量

一些常量可以在Rust标准库中找到。

e      pi

示例

pi * 5^2  # πr²

函数

所有三角函数均以度为单位输入。

1 argument:
sin    cos     tan    csc    sec    cot    sinh   cosh   tanh
asin   acos    atan   acsc   asec   acot   ln     log10  sqrt
ceil   floor   abs

2 arguments:
log    nroot

deg(x) - convert x to degrees
rad(x) - convert x to radians

示例

sqrt(sin(30)) # parentheses are mandatory for functions

log10100      # no
log10(100)    # yes

log(1, 10)    # function with two arguments

生活品质功能

  • 自动插入 * 运算符
>12sin(45(2))             # 12 * sin(45 * (2))
12
  • 自动平衡括号
>ceil(sqrt(3^2 + 5^2      # ceil(sqrt(3^2 + 5^2))
6
  • 使用 _ 使用上一个答案
> sin(pi)
0.0548036650
> _^2
0.0030034417
>
  • 出色的错误处理
> 1 + ln(-1)
Domain Error: Out of bounds!
  • 语法高亮

待办事项

  • 添加对变量的支持(pi,e,_(上一个答案))
  • 语法高亮
  • 多参数函数
  • 屏幕截图
  • 创建标志
  • 一元运算符(减号,加号)
  • 添加详细的错误处理器
  • 添加单元测试
  • lineditor 带语法高亮
  • 添加更多功能

贡献者

Rust社区帮助eva取得了长足的进步,但以下开发者因其贡献而应特别提及

Ivan Tham
Milan Marković
asapokl

依赖关系

~8–22MB
~273K SLoC