mirror of https://github.com/rm-dr/daisy
Compare commits
No commits in common. "228cbf281f95740cc953b81e9e7a4df33f96e24c" and "1fae11a3805e938a3794280211fb919689701411" have entirely different histories.
228cbf281f
...
1fae11a380
|
@ -4,7 +4,7 @@ version = "1.1.7"
|
|||
edition = "2021"
|
||||
build = "buildscript/main.rs"
|
||||
license = "GPL-3.0-only"
|
||||
description = "A pretty TUI scientific calculator."
|
||||
description = "A high-precision terminal scientific calculator."
|
||||
repository = "https://git.betalupi.com/Mark/daisy"
|
||||
homepage = "https://git.betalupi.com/Mark/daisy"
|
||||
readme = "README.md"
|
||||
|
|
10
README.md
10
README.md
|
@ -1,6 +1,6 @@
|
|||
![](./server/site/resources/readme-banner.png)
|
||||
|
||||
A pretty, general-purpose scientific calculator with support for units, derivatives, and more.
|
||||
A high-precision scientific calculator with support for units, derivatives, and more.
|
||||
|
||||
Many features are missing, this is still under development.
|
||||
|
||||
|
@ -33,7 +33,9 @@ in
|
|||
|
||||
# 🛠️ Features
|
||||
- Open-source
|
||||
- Carefully designed and easy-to-read prompt
|
||||
- Extremely high precision
|
||||
- Uses a rational datatype when possible, and a high-precision float when not.
|
||||
- Pretty printing in prompt (with special substitutions)
|
||||
- Supports many physical units, with metric and binary prefixes
|
||||
- Supports exponential notation
|
||||
- Clear syntax, parsed input is always re-printed as a sanity check.
|
||||
|
@ -75,10 +77,6 @@ Daisy instead provides four functions (`fromCelsius`, `toCelsius`, `fromFahrenhe
|
|||
- "from" functions take a scalar and return a value in Kelvin: `fromCelsius(0) = 273.15K`
|
||||
- "to" functions take a value in Kelvin and return a scalar: `toCelsius(273.15 K) = 0`
|
||||
|
||||
Functions `FtoC` and `CtoF` are also provided:
|
||||
- `FtoC(x) = toCelsius(fromFahrenheit(x))`
|
||||
- `CtoF(x) = toFahrenheit(fromCelsius(x))`
|
||||
|
||||
|
||||
## Multiplication Order
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
|
||||
<div id="header">
|
||||
<img id="banner" src = "resources/daisy-light.svg" alt="Daisy Banner"/>
|
||||
<p>A pretty, general-purpose scientific calculator</p>
|
||||
<p>A high-precision, general-purpose scientific calculator</p>
|
||||
</div>
|
||||
|
||||
<div id="terminal"></div>
|
||||
|
|
|
@ -57,8 +57,8 @@ pub fn do_command(
|
|||
|
||||
t.push(
|
||||
concat!(
|
||||
"Daisy is a pretty, general-purpose\n",
|
||||
"TUI scientific calculator.\n",
|
||||
"Daisy is a high-precision, general-purpose\n",
|
||||
"scientific calculator.\n",
|
||||
"\n",
|
||||
" - Use Up/Down arrows to navigate history.\n",
|
||||
" - Use Ctrl-C or Ctrl-D to quit.\n",
|
||||
|
@ -152,9 +152,6 @@ pub fn do_command(
|
|||
" Fahrenheit to Kelvin [c]fromF, fromFahrenheit[n]\n",
|
||||
" Kelvin to Fahrenheit [c]toF, toFahrenheit[n]\n",
|
||||
"\n",
|
||||
" Celsius to Fahrenheit [c]CtoF[n]\n",
|
||||
" Fahrenheit to Celsius [c]FtoC[n]\n",
|
||||
"\n",
|
||||
" convert to base unit [c]tobase[n]\n",
|
||||
" remove units [c]nounit[n]\n",
|
||||
"\n\n"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use std::collections::VecDeque;
|
||||
|
||||
use crate::parser::Expression;
|
||||
use crate::parser::Function;
|
||||
use crate::parser::Operator;
|
||||
|
@ -11,7 +9,6 @@ use crate::quantity::Quantity;
|
|||
use crate::quantity::Scalar;
|
||||
use crate::errors::DaisyError;
|
||||
use crate::context::Context;
|
||||
use super::evaluate;
|
||||
|
||||
// If unitless, do nothing
|
||||
// If compatible with radians, convert to radians and return unitless
|
||||
|
@ -154,33 +151,6 @@ pub fn eval_function(context: &mut Context, g: &Expression) -> Result<Option<Exp
|
|||
},
|
||||
|
||||
|
||||
Function::CtoF => {
|
||||
return Ok(evaluate(context,
|
||||
&Expression::Operator(
|
||||
*l + *loc,
|
||||
Operator::Function(Function::ToFahrenheit),
|
||||
VecDeque::from(vec![Expression::Operator(
|
||||
*l + *loc,
|
||||
Operator::Function(Function::FromCelsius),
|
||||
VecDeque::from(vec![Expression::Quantity(*l, q.clone())])
|
||||
)])
|
||||
)
|
||||
).ok());
|
||||
},
|
||||
|
||||
Function::FtoC => {
|
||||
return Ok(evaluate(context,
|
||||
&Expression::Operator(
|
||||
*l + *loc,
|
||||
Operator::Function(Function::ToCelsius),
|
||||
VecDeque::from(vec![Expression::Operator(
|
||||
*l + *loc,
|
||||
Operator::Function(Function::FromFahrenheit),
|
||||
VecDeque::from(vec![Expression::Quantity(*l, q.clone())])
|
||||
)])
|
||||
)
|
||||
).ok());
|
||||
},
|
||||
|
||||
Function::ToCelsius => {
|
||||
let mut k = Quantity::new_rational(1f64).unwrap();
|
||||
|
|
|
@ -37,9 +37,7 @@ pub enum Function {
|
|||
FromCelsius,
|
||||
ToCelsius,
|
||||
FromFahrenheit,
|
||||
ToFahrenheit,
|
||||
CtoF,
|
||||
FtoC,
|
||||
ToFahrenheit
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,8 +74,6 @@ impl ToString for Function {
|
|||
Function::ToCelsius => {String::from("tocelsius") },
|
||||
Function::FromFahrenheit => { String::from("fromfahrenheit") },
|
||||
Function::ToFahrenheit => { String::from("tofahrenheit") },
|
||||
Function::FtoC => { String::from("FtoC") },
|
||||
Function::CtoF => { String::from("CtoF") },
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,11 +126,6 @@ impl Function {
|
|||
"fromF" => {Some(Function::FromFahrenheit)},
|
||||
"fromfahrenheit" => {Some(Function::FromFahrenheit)},
|
||||
"fromFahrenheit" => {Some(Function::FromFahrenheit)},
|
||||
|
||||
"FtoC" => {Some(Function::FtoC)},
|
||||
"ftoc" => {Some(Function::FtoC)},
|
||||
"ctof" => {Some(Function::CtoF)},
|
||||
"CtoF" => {Some(Function::CtoF)},
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,11 +232,5 @@ fn functions() {
|
|||
|
||||
good_expr("2", "nounit(2 mm)");
|
||||
good_expr("2", "nounit(2 meter * second)");
|
||||
|
||||
good_expr("37.778", "FtoC(100)");
|
||||
good_expr("73.399", "CtoF(23)");
|
||||
good_expr("-17.778", "FtoC(0)");
|
||||
good_expr("31.999", "CtoF(0)");
|
||||
|
||||
//good_expr("5000 m²·g/(s²·A²)", "tobase(5H)");
|
||||
}
|
Loading…
Reference in New Issue