Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gleam-community/maths
A basic mathematics library containing fundamental functions and utilities.
https://github.com/gleam-community/maths
gleam gleam-community gleam-lang mathematics maths
Last synced: about 2 months ago
JSON representation
A basic mathematics library containing fundamental functions and utilities.
- Host: GitHub
- URL: https://github.com/gleam-community/maths
- Owner: gleam-community
- License: apache-2.0
- Created: 2022-12-21T18:27:56.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-10T21:17:39.000Z (5 months ago)
- Last Synced: 2024-04-11T00:43:36.605Z (5 months ago)
- Topics: gleam, gleam-community, gleam-lang, mathematics, maths
- Language: Gleam
- Homepage:
- Size: 171 KB
- Stars: 17
- Watchers: 4
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
- awesome-gleam - gleam_community_maths - [📚](https://hexdocs.pm/gleam_community_maths/) - A basic maths library (Packages / Numbers)
README
# gleam-community/maths
[![Package Version](https://img.shields.io/hexpm/v/gleam_community_maths)](https://hex.pm/packages/gleam_community_maths)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/gleam_community_maths/)A basic mathematics library that contains some of the most fundamental mathematics functions and utilities.
The library supports both targets: Erlang and JavaScript.
## Quickstart
```gleam
import gleam_community/maths/arithmetics
import gleam_community/maths/combinatorics
import gleam_community/maths/elementary
import gleam_community/maths/piecewise
import gleam_community/maths/predicates
import gleam/float
import gleam/intpub fn main() {
// Evaluate the sine function
elementary.sin(elementary.pi())
// Returns Float: 0.0// Find the greatest common divisor
arithmetics.gcd(54, 24)
// Returns Int: 6// Find the minimum and maximum of a list
piecewise.extrema([10.0, 3.0, 50.0, 20.0, 3.0], float.compare)
// Returns Tuple: Ok(#(3.0, 50.0))// Find the list indices of the smallest value
piecewise.arg_minimum([10, 3, 50, 20, 3], int.compare)
// Returns List: Ok([1, 4])// Determine if a number is fractional
predicates.is_fractional(0.3333)
// Returns Bool: True// Determine if 28 is a power of 3
predicates.is_power(28, 3)
// Returns Bool: False// Generate all k = 1 combinations of [1, 2]
combinatorics.list_combination([1, 2], 1)
// Returns List: Ok([[1], [2]])
}
```## Installation
`gleam_community` packages are published to [hex.pm](https://hex.pm/packages/gleam_community_maths)
with the prefix `gleam_community_`. You can add them to your Gleam projects directly:```sh
gleam add gleam_community_maths
```