package calc import ( "gitea.zaclys.com/bvaudour/gob/number" "gitea.zaclys.com/bvaudour/gob/option" ) func Push(numbers ...number.Number) CalcFunc { return func(c *Calc) (err option.Option[error]) { c.Push(numbers...) return } } // Gestion de la pile func Pop(c *Calc) option.Option[error] { return c.Pop() } func Reset(c *Calc) option.Option[error] { return c.Reset() } func Duplicate(c *Calc) option.Option[error] { return c.Duplicate() } func DuplicateStack(c *Calc) option.Option[error] { return c.DuplicateStack() } func Reverse(c *Calc) option.Option[error] { return c.Reverse() } func ReverseStack(c *Calc) option.Option[error] { return c.ReverseStack() } func Sort(c *Calc) option.Option[error] { return c.Sort() } func SortDesc(c *Calc) option.Option[error] { return c.SortDesc() } // Gestion du registre func ResetRegistry(k string) CalcFunc { return func(c *Calc) option.Option[error] { return c.ResetRegistry(k) } } func ResetRegistries(c *Calc) option.Option[error] { return c.ResetRegistries() } func Store(k string) CalcFunc { return func(c *Calc) option.Option[error] { return c.Store(k) } } func StoreStack(k string) CalcFunc { return func(c *Calc) option.Option[error] { return c.StoreStack(k) } } func Load(k string) CalcFunc { return func(c *Calc) option.Option[error] { return c.Load(k) } } // Gestion des macros func ResetMacro(k string) CalcFunc { return func(c *Calc) option.Option[error] { return c.ResetMacro(k) } } func ResetMacros(c *Calc) option.Option[error] { return c.ResetMacros() } func StoreMacro(k string, args ...MacroElement) CalcFunc { return func(c *Calc) (err option.Option[error]) { c.StoreMacro(k, args...) return } } func Exec(s MacroStack) CalcErrFunc { return func(c *Calc) []error { return c.Exec(s) } } func ExecMacro(k string) CalcErrFunc { return func(c *Calc) []error { return c.ExecMacro(k) } } func If(e1, e2 MacroElement) CalcFunc { return func(c *Calc) option.Option[error] { return c.If(e1, e2) } } // Aucune action func NoAction(c *Calc) option.Option[error] { return c.NoAction() } var ( // Opérations mathématiques Abs = Op1(number.Abs) Neg = Op1(number.Neg) Inc = Op1(number.Inc) Dec = Op1(number.Dec) Inv = Op1(number.Inv) Add = Op2(number.Add) Sub = Op2(number.Sub) Mul = Op2(number.Mul) Div = Op2(number.Div) Quo = Op2(number.Quo) Rem = Op2(number.Rem) Square = Op1(number.Square) Pow = Op2(number.Pow) Sqrt = Op1(number.Sqrt) Sqrtn = Op2(number.Sqrtn) Fact = Op1(number.Fact) // Opérations de comparaison Cmp = Op2(number.Cmp) Eq = Op2(number.Eq) Ne = Op2(number.Ne) Gt = Op2(number.Gt) Lt = Op2(number.Lt) Ge = Op2(number.Ge) Le = Op2(number.Le) // Opérations sur les bits Lsh = Op2(number.Lsh) Rsh = Op2(number.Rsh) Bit = Op2(number.Bit) // Fonctions statistiques Sum = Reduce(number.Sum) Min = Reduce(number.Min) Max = Reduce(number.Max) Mean = Reduce(number.Mean) Median = Reduce(number.Median) Mode = Reduce(number.Mode) Variance = Reduce(number.Variance) StdDeviation = Reduce(number.StdDeviation) ) // Conversions func ToBase[N integer](base N) CalcFunc { return Op1(ConvertToBase(base)) } func ToInteger[N integer](base ...N) CalcFunc { return Op1(ConvertToInteger(base...)) } func ToDecimal[N integer](base ...N) CalcFunc { return Op1(ConvertToDecimal(base...)) } func ToFraction[N integer](base ...N) CalcFunc { return Op1(ConvertToFraction(base...)) } func ToScientific[N integer](base ...N) CalcFunc { return Op1(ConvertToScientific(base...)) } func Round(precision uint64, base ...uint) CalcFunc { return Op1(ConvertRound(precision, base...)) }