1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 22:57:46 +00:00

FIX: the math functions can not be used (#381)

* remove the `pi` and `e` constants

This commit mitigates the following error
```bash
> use maths/math_functions.nu
Error: nu::parser::expected_keyword (link)

  × Expected keyword.
    ╭─[maths/math_functions.nu:38:1]
 38 │ ## constants
 39 │ let pi = 3.1415926535897932
    · ─┬─
    ·  ╰── expected def or export keyword
 40 │ let e  = 2.7182818284590452
    ╰────
```

One can use the new `math pi` and `math e` instead.

* switch from `for` to `each` in pipelines

This commit mitigates the following error
```bash
> use maths/math_functions.nu
Error: nu::parser::unexpected_keyword (link)

  × Statement used in pipeline.
     ╭─[maths/math_functions.nu:154:1]
 154 │
 155 │     for $i in 0..($n_cols - 1) {
     ·     ─┬─
     ·      ╰── not allowed in pipeline
 156 │         ($x | column2 $i) | scale-minmax $a $b | wrap ($name_cols | get $i)
     ╰────
  help: 'for' keyword is not allowed in
        pipeline. Use 'for' by itself,
        outside of a pipeline.
```
This commit is contained in:
Antoine Stevan 2023-02-18 20:19:55 +01:00 committed by GitHub
parent 274464369f
commit fa5f262a5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -34,11 +34,6 @@ export def fact [num: int] {
}
}
### Added by kira
## constants
let pi = 3.1415926535897932
let e = 2.7182818284590452
#Calculate roots of the quadratic function: ax^2+bx+x
export def q_roots [
a # x^2
@ -157,7 +152,8 @@ export def scale-minmax-table [a, b,input?] {
let n_cols = ($x | transpose | length)
let name_cols = ($x | transpose | column2 0)
for $i in 0..($n_cols - 1) {
0..($n_cols - 1)
| each {|i|
($x | column2 $i) | scale-minmax $a $b | wrap ($name_cols | get $i)
} | reduce {|it, acc| $acc | merge {$it}}
}