diff options
author | Ethan Thoma <ethanthoma@gmail.com> | 2024-12-21 14:09:12 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-21 22:09:12 +0000 |
commit | 9d76bea763732dee0358feaeae46840cb75093be (patch) | |
tree | 767277049d9bedd56652ebf378cd35db3e98c4a3 /src/gleam_stdlib.mjs | |
parent | 9dee307c7f1fa0641975c98a81da0b6f763c24b5 (diff) | |
download | gleam_stdlib-9d76bea763732dee0358feaeae46840cb75093be.tar.gz gleam_stdlib-9d76bea763732dee0358feaeae46840cb75093be.zip |
Add `sample` function to List module, add `log` and `exp` functions to Float module (#772)
Diffstat (limited to 'src/gleam_stdlib.mjs')
-rw-r--r-- | src/gleam_stdlib.mjs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/gleam_stdlib.mjs b/src/gleam_stdlib.mjs index 4f804f7..339963b 100644 --- a/src/gleam_stdlib.mjs +++ b/src/gleam_stdlib.mjs @@ -1010,3 +1010,16 @@ export function bit_array_starts_with(bits, prefix) { return true; } + +export function log(x) { + // It is checked in Gleam that: + // - The input is strictly positive (x > 0) + // - This ensures that Math.log will never return NaN or -Infinity + // The function can thus safely pass the input to Math.log + // and a valid finite float will always be produced. + return Math.log(x); +} + +export function exp(x) { + return Math.exp(x); +} |