add log
to expressions (#1271)
* feat: add `log` to expressions * changelog: add `log`
This commit is contained in:
parent
a7bd80ac1e
commit
593a4f4666
3 changed files with 10 additions and 0 deletions
|
@ -31,6 +31,7 @@ All notable changes to eww will be listed here, starting at changes since versio
|
||||||
- Add `transform-origin-x`/`transform-origin-y` properties to transform widget (By: mario-kr)
|
- Add `transform-origin-x`/`transform-origin-y` properties to transform widget (By: mario-kr)
|
||||||
- Add keyboard support for button presses (By: julianschuler)
|
- Add keyboard support for button presses (By: julianschuler)
|
||||||
- Support empty string for safe access operator (By: ModProg)
|
- Support empty string for safe access operator (By: ModProg)
|
||||||
|
- Add `log` function calls to simplexpr (By: topongo)
|
||||||
|
|
||||||
## [0.6.0] (21.04.2024)
|
## [0.6.0] (21.04.2024)
|
||||||
|
|
||||||
|
|
|
@ -500,6 +500,14 @@ fn call_expr_function(name: &str, args: Vec<DynVal>) -> Result<DynVal, EvalError
|
||||||
})),
|
})),
|
||||||
_ => Err(EvalError::WrongArgCount(name.to_string())),
|
_ => Err(EvalError::WrongArgCount(name.to_string())),
|
||||||
},
|
},
|
||||||
|
"log" => match args.as_slice() {
|
||||||
|
[num, n] => {
|
||||||
|
let num = num.as_f64()?;
|
||||||
|
let n = n.as_f64()?;
|
||||||
|
Ok(DynVal::from(f64::log(num, n)))
|
||||||
|
}
|
||||||
|
_ => Err(EvalError::WrongArgCount(name.to_string())),
|
||||||
|
},
|
||||||
|
|
||||||
_ => Err(EvalError::UnknownFunction(name.to_string())),
|
_ => Err(EvalError::UnknownFunction(name.to_string())),
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ Supported currently are the following features:
|
||||||
- `sin(number)`, `cos(number)`, `tan(number)`, `cot(number)`: Calculate the trigonometric value of a given number in **radians**
|
- `sin(number)`, `cos(number)`, `tan(number)`, `cot(number)`: Calculate the trigonometric value of a given number in **radians**
|
||||||
- `min(a, b)`, `max(a, b)`: Get the smaller or bigger number out of two given numbers
|
- `min(a, b)`, `max(a, b)`: Get the smaller or bigger number out of two given numbers
|
||||||
- `powi(num, n)`, `powf(num, n)`: Raise number `num` to power `n`. `powi` expects `n` to be of type `i32`
|
- `powi(num, n)`, `powf(num, n)`: Raise number `num` to power `n`. `powi` expects `n` to be of type `i32`
|
||||||
|
- `log(num, n)`: Calculate the base `n` logarithm of `num`. `num`, `n` and return type are `f64`
|
||||||
- `degtorad(number)`: Converts a number from degrees to radians
|
- `degtorad(number)`: Converts a number from degrees to radians
|
||||||
- `radtodeg(number)`: Converts a number from radians to degrees
|
- `radtodeg(number)`: Converts a number from radians to degrees
|
||||||
- `replace(string, regex, replacement)`: Replace matches of a given regex in a string
|
- `replace(string, regex, replacement)`: Replace matches of a given regex in a string
|
||||||
|
|
Loading…
Add table
Reference in a new issue