mirror of
https://github.com/janet-lang/janet
synced 2025-01-24 06:06:52 +00:00
Add mean function to boot.janet
Update changelog.
This commit is contained in:
parent
908a3b6f5c
commit
8e427317cd
@ -2,6 +2,8 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
- Fix an issue that prevent some valid programs from compiling.
|
||||||
|
- Add `mean` to core.
|
||||||
- Allow (length x) on typed arrays an other abstract types that implement
|
- Allow (length x) on typed arrays an other abstract types that implement
|
||||||
the :length method.
|
the :length method.
|
||||||
|
|
||||||
|
@ -445,6 +445,11 @@
|
|||||||
(each x xs (+= accum x))
|
(each x xs (+= accum x))
|
||||||
accum)
|
accum)
|
||||||
|
|
||||||
|
(defn mean
|
||||||
|
"Returns the mean of xs. If empty, returns NaN."
|
||||||
|
[xs]
|
||||||
|
(/ (sum xs) (length xs)))
|
||||||
|
|
||||||
(defn product
|
(defn product
|
||||||
"Returns the product of xs. If xs is empty, returns 1."
|
"Returns the product of xs. If xs is empty, returns 1."
|
||||||
[xs]
|
[xs]
|
||||||
|
Loading…
Reference in New Issue
Block a user