Skip to content

Remove math eval and fully replace it with pure nushell implementation #7073

@sholderbach

Description

@sholderbach

Related problem

We currently have math eval that takes a string and parses and executes math in it through the meval crate.
This creates two sources of truth how math behaves in nushell.

Further more the crate carries some out of date dependencies, causing dependency duplication.

Describe the solution you'd like

For nu to be a fully useable scripting language there should be a library of math functions that are implemented with proper care (may be part of the core or a plugin).
math eval shouldn't be necessary or trivially implementable in nu code.

Describe alternatives you've considered

Hot take: If you need string math bc is still around, but math eval is only slightly more compatible with nushell/

List of missing math commands:

Compare to https://docs.rs/meval/latest/meval/#supported-expressions

Exponentiation

  • pow/ general exponentiation
  • exp,
  • ln
  • logs in other bases for convenience/numerical stability reasons

Trigonometry

  • sin
  • cos
  • tan
  • asin
  • acos
  • atan
  • atan2
  • sinh
  • cosh
  • tanh
  • asinh
  • acosh
  • atanh

Utilities

  • signum (get the sign cheaply)
  • modulo

constants:

  • pi
  • e

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions