No description
Find a file
Nicklas Sindlev Andersen 373bdd1675
Merge pull request #14 from skyl4b/patch-1
fix: small typo on incomplete_gamma error
2024-03-16 22:05:35 +01:00
.github/workflows Update workflows 2024-03-12 00:22:31 +01:00
src fix: small typo on incomplete_gamma error 2024-03-16 12:56:23 -03:00
test Add extra tests. Improve Euclidean modulo description. 2024-03-11 23:59:07 +01:00
.gitignore Initial commit 2022-12-23 15:26:58 +01:00
CODE_OF_CONDUCT.md Add CoD, codeowners + licence 2023-01-29 23:48:48 +01:00
CODEOWNERS Add CoD, codeowners + licence 2023-01-29 23:48:48 +01:00
gleam.toml Increment version number 2024-03-12 00:16:05 +01:00
LICENCE Add CoD, codeowners + licence 2023-01-29 23:48:48 +01:00
manifest.toml Add extra tests. Improve Euclidean modulo description. 2024-03-11 23:59:07 +01:00
README.md Fix README example 2024-03-12 00:02:20 +01:00

gleam-community/maths

Package Version Hex Docs

A basic mathematics library that contains some of the most fundamental mathematics functions and utilities.

The library supports both targets: Erlang and JavaScript.

Quickstart

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/int

pub 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 with the prefix gleam_community_. You can add them to your Gleam projects directly:

gleam add gleam_community_maths