mirror of
https://github.com/janet-lang/janet
synced 2025-01-23 21:56: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.
|
||||
|
||||
## 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.
|
||||
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user