Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More statistics, list and string functions #468

Merged
merged 6 commits into from
Jun 13, 2024

Conversation

sharkdp
Copy link
Owner

@sharkdp sharkdp commented Jun 13, 2024

This PR adds the following functions — all implemented in Numbat!

Statistics:

@name("Variance")
@url("https://en.wikipedia.org/wiki/Variance")
@description("Calculate the population variance of a list of quantities")
fn variance<D: Dim>(xs: List<D>) -> D^2

@name("Standard deviation")
@url("https://en.wikipedia.org/wiki/Standard_deviation")
@description("Calculate the population standard deviation of a list of quantities")
fn stdev<D: Dim>(xs: List<D>) -> D

@name("Median")
@url("https://en.wikipedia.org/wiki/Median")
@description("Calculate the median of a list of quantities")
fn median<D: Dim>(xs: List<D>) -> D

Lists:

@description("Get the first `n` elements of a list")
fn take<A>(n: Scalar, xs: List<A>) -> List<A>

@description("Get everything but the first `n` elements of a list")
fn drop<A>(n: Scalar, xs: List<A>) -> List<A>

@description("Get the element at index `i` in a list")
fn element_at<A>(i: Scalar, xs: List<A>) -> A

@description("Sort a list of quantities")
fn sort<D: Dim>(xs: List<D>) -> List<D>

Lists and strings:

@description("Convert a list of strings into a single string by concatenating them with a separator")
fn join(xs: List<String>, sep: String)

@description("Split a string into a list of strings using a separator")
fn split(input: String, separator: String) -> List<String>

Strings

fn str_find(haystack: String, needle: String) -> Scalar

related ticket: #144

@sharkdp sharkdp merged commit 2a7d0c1 into master Jun 13, 2024
15 checks passed
@sharkdp sharkdp deleted the more-list-and-string-functions branch June 13, 2024 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant