forked from extern/nushell
cratification: part II of the math commands to nu-cmd-extra (#9657)
The following math commands are being moved to nu-cmd-extra * cos * cosh * egamma * phi * pi * sin * sinh * tan * tanh * tau For now I think we have most of the obvious commands moved over based on @sholderbach this should cover moving the "high school" commands.. >>Yeah I think this rough separation into "high school" math in extra and "middle school"/"programmer" math in the core makes a ton of sense. And to reference the @fdncred list from https://github.com/nushell/nushell/pull/9647#issuecomment-1629498812
This commit is contained in:
parent
e10d84b72f
commit
942c66a9f3
@ -15,6 +15,7 @@ mod test_examples {
|
|||||||
check_example_input_and_output_types_match_command_signature,
|
check_example_input_and_output_types_match_command_signature,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::MathPi;
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
engine::{Command, EngineState, StateWorkingSet},
|
engine::{Command, EngineState, StateWorkingSet},
|
||||||
Type,
|
Type,
|
||||||
@ -63,6 +64,9 @@ mod test_examples {
|
|||||||
|
|
||||||
working_set.add_decl(Box::new(nu_command::Enumerate));
|
working_set.add_decl(Box::new(nu_command::Enumerate));
|
||||||
working_set.add_decl(Box::new(nu_cmd_lang::If));
|
working_set.add_decl(Box::new(nu_cmd_lang::If));
|
||||||
|
// math commands
|
||||||
|
working_set.add_decl(Box::new(MathPi));
|
||||||
|
working_set.add_decl(Box::new(nu_command::MathRound));
|
||||||
|
|
||||||
// Adding the command that is being tested to the working set
|
// Adding the command that is being tested to the working set
|
||||||
working_set.add_decl(cmd);
|
working_set.add_decl(cmd);
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
|
mod cos;
|
||||||
|
mod cosh;
|
||||||
|
mod sin;
|
||||||
|
mod sinh;
|
||||||
|
mod tan;
|
||||||
|
mod tanh;
|
||||||
|
|
||||||
|
mod egamma;
|
||||||
|
mod phi;
|
||||||
|
mod pi;
|
||||||
|
mod tau;
|
||||||
|
|
||||||
mod arccos;
|
mod arccos;
|
||||||
mod arccosh;
|
mod arccosh;
|
||||||
mod arcsin;
|
mod arcsin;
|
||||||
@ -5,6 +17,18 @@ mod arcsinh;
|
|||||||
mod arctan;
|
mod arctan;
|
||||||
mod arctanh;
|
mod arctanh;
|
||||||
|
|
||||||
|
pub use cos::SubCommand as MathCos;
|
||||||
|
pub use cosh::SubCommand as MathCosH;
|
||||||
|
pub use sin::SubCommand as MathSin;
|
||||||
|
pub use sinh::SubCommand as MathSinH;
|
||||||
|
pub use tan::SubCommand as MathTan;
|
||||||
|
pub use tanh::SubCommand as MathTanH;
|
||||||
|
|
||||||
|
pub use egamma::SubCommand as MathEulerGamma;
|
||||||
|
pub use phi::SubCommand as MathPhi;
|
||||||
|
pub use pi::SubCommand as MathPi;
|
||||||
|
pub use tau::SubCommand as MathTau;
|
||||||
|
|
||||||
pub use arccos::SubCommand as MathArcCos;
|
pub use arccos::SubCommand as MathArcCos;
|
||||||
pub use arccosh::SubCommand as MathArcCosH;
|
pub use arccosh::SubCommand as MathArcCosH;
|
||||||
pub use arcsin::SubCommand as MathArcSin;
|
pub use arcsin::SubCommand as MathArcSin;
|
||||||
|
@ -31,6 +31,18 @@ pub use bits::BitsShl;
|
|||||||
pub use bits::BitsShr;
|
pub use bits::BitsShr;
|
||||||
pub use bits::BitsXor;
|
pub use bits::BitsXor;
|
||||||
|
|
||||||
|
pub use math::MathCos;
|
||||||
|
pub use math::MathCosH;
|
||||||
|
pub use math::MathSin;
|
||||||
|
pub use math::MathSinH;
|
||||||
|
pub use math::MathTan;
|
||||||
|
pub use math::MathTanH;
|
||||||
|
|
||||||
|
pub use math::MathEulerGamma;
|
||||||
|
pub use math::MathPhi;
|
||||||
|
pub use math::MathPi;
|
||||||
|
pub use math::MathTau;
|
||||||
|
|
||||||
pub use math::MathArcCos;
|
pub use math::MathArcCos;
|
||||||
pub use math::MathArcCosH;
|
pub use math::MathArcCosH;
|
||||||
pub use math::MathArcSin;
|
pub use math::MathArcSin;
|
||||||
@ -113,7 +125,15 @@ pub fn add_extra_command_context(mut engine_state: EngineState) -> EngineState {
|
|||||||
MathArcTan,
|
MathArcTan,
|
||||||
MathArcSinH,
|
MathArcSinH,
|
||||||
MathArcCosH,
|
MathArcCosH,
|
||||||
MathArcTanH
|
MathArcTanH,
|
||||||
|
MathSin,
|
||||||
|
MathCos,
|
||||||
|
MathTan,
|
||||||
|
MathSinH,
|
||||||
|
MathCosH,
|
||||||
|
MathTanH,
|
||||||
|
MathPi,
|
||||||
|
MathTau
|
||||||
};
|
};
|
||||||
|
|
||||||
working_set.render()
|
working_set.render()
|
||||||
|
@ -327,14 +327,6 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState {
|
|||||||
MathStddev,
|
MathStddev,
|
||||||
MathSum,
|
MathSum,
|
||||||
MathVariance,
|
MathVariance,
|
||||||
MathSin,
|
|
||||||
MathCos,
|
|
||||||
MathTan,
|
|
||||||
MathSinH,
|
|
||||||
MathCosH,
|
|
||||||
MathTanH,
|
|
||||||
MathPi,
|
|
||||||
MathTau,
|
|
||||||
MathEuler,
|
MathEuler,
|
||||||
MathExp,
|
MathExp,
|
||||||
MathLn,
|
MathLn,
|
||||||
|
@ -9,9 +9,9 @@ pub fn test_examples(cmd: impl Command + 'static) {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_examples {
|
mod test_examples {
|
||||||
use super::super::{
|
use super::super::{
|
||||||
Ansi, Date, Enumerate, Flatten, From, Get, Into, IntoString, Math, MathEuler, MathPi,
|
Ansi, Date, Enumerate, Flatten, From, Get, Into, IntoString, Math, MathEuler, MathRound,
|
||||||
MathRound, ParEach, Path, PathParse, Random, Sort, SortBy, Split, SplitColumn, SplitRow,
|
ParEach, Path, PathParse, Random, Sort, SortBy, Split, SplitColumn, SplitRow, Str, StrJoin,
|
||||||
Str, StrJoin, StrLength, StrReplace, Update, Url, Values, Wrap,
|
StrLength, StrReplace, Update, Url, Values, Wrap,
|
||||||
};
|
};
|
||||||
use crate::{Each, To};
|
use crate::{Each, To};
|
||||||
use nu_cmd_lang::example_support::{
|
use nu_cmd_lang::example_support::{
|
||||||
@ -80,7 +80,6 @@ mod test_examples {
|
|||||||
working_set.add_decl(Box::new(Let));
|
working_set.add_decl(Box::new(Let));
|
||||||
working_set.add_decl(Box::new(Math));
|
working_set.add_decl(Box::new(Math));
|
||||||
working_set.add_decl(Box::new(MathEuler));
|
working_set.add_decl(Box::new(MathEuler));
|
||||||
working_set.add_decl(Box::new(MathPi));
|
|
||||||
working_set.add_decl(Box::new(MathRound));
|
working_set.add_decl(Box::new(MathRound));
|
||||||
working_set.add_decl(Box::new(Mut));
|
working_set.add_decl(Box::new(Mut));
|
||||||
working_set.add_decl(Box::new(Path));
|
working_set.add_decl(Box::new(Path));
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
mod abs;
|
mod abs;
|
||||||
mod avg;
|
mod avg;
|
||||||
mod ceil;
|
mod ceil;
|
||||||
mod cos;
|
|
||||||
mod cosh;
|
|
||||||
mod egamma;
|
|
||||||
mod euler;
|
mod euler;
|
||||||
mod exp;
|
mod exp;
|
||||||
mod floor;
|
mod floor;
|
||||||
@ -14,19 +11,12 @@ mod max;
|
|||||||
mod median;
|
mod median;
|
||||||
mod min;
|
mod min;
|
||||||
mod mode;
|
mod mode;
|
||||||
mod phi;
|
|
||||||
mod pi;
|
|
||||||
mod product;
|
mod product;
|
||||||
mod reducers;
|
mod reducers;
|
||||||
mod round;
|
mod round;
|
||||||
mod sin;
|
|
||||||
mod sinh;
|
|
||||||
mod sqrt;
|
mod sqrt;
|
||||||
mod stddev;
|
mod stddev;
|
||||||
mod sum;
|
mod sum;
|
||||||
mod tan;
|
|
||||||
mod tanh;
|
|
||||||
mod tau;
|
|
||||||
mod utils;
|
mod utils;
|
||||||
mod variance;
|
mod variance;
|
||||||
|
|
||||||
@ -46,18 +36,7 @@ pub use stddev::SubCommand as MathStddev;
|
|||||||
pub use sum::SubCommand as MathSum;
|
pub use sum::SubCommand as MathSum;
|
||||||
pub use variance::SubCommand as MathVariance;
|
pub use variance::SubCommand as MathVariance;
|
||||||
|
|
||||||
pub use cos::SubCommand as MathCos;
|
|
||||||
pub use cosh::SubCommand as MathCosH;
|
|
||||||
pub use sin::SubCommand as MathSin;
|
|
||||||
pub use sinh::SubCommand as MathSinH;
|
|
||||||
pub use tan::SubCommand as MathTan;
|
|
||||||
pub use tanh::SubCommand as MathTanH;
|
|
||||||
|
|
||||||
pub use egamma::SubCommand as MathEulerGamma;
|
|
||||||
pub use euler::SubCommand as MathEuler;
|
pub use euler::SubCommand as MathEuler;
|
||||||
pub use phi::SubCommand as MathPhi;
|
|
||||||
pub use pi::SubCommand as MathPi;
|
|
||||||
pub use tau::SubCommand as MathTau;
|
|
||||||
|
|
||||||
pub use self::log::SubCommand as MathLog;
|
pub use self::log::SubCommand as MathLog;
|
||||||
pub use exp::SubCommand as MathExp;
|
pub use exp::SubCommand as MathExp;
|
||||||
|
Loading…
Reference in New Issue
Block a user