Add mean function to boot.janet

Update changelog.
This commit is contained in:
Calvin Rose 2019-09-19 20:26:16 -05:00
parent 908a3b6f5c
commit 8e427317cd
2 changed files with 7 additions and 0 deletions

View File

@ -2,6 +2,8 @@
All notable changes to this project will be documented in this file.
## 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
the :length method.

View File

@ -445,6 +445,11 @@
(each x xs (+= accum x))
accum)
(defn mean
"Returns the mean of xs. If empty, returns NaN."
[xs]
(/ (sum xs) (length xs)))
(defn product
"Returns the product of xs. If xs is empty, returns 1."
[xs]