{"id":13741401,"url":"https://github.com/gleam-community/maths","last_synced_at":"2026-01-14T16:40:48.142Z","repository":{"id":124298295,"uuid":"580898222","full_name":"gleam-community/maths","owner":"gleam-community","description":"A basic mathematics library containing fundamental functions and utilities.","archived":false,"fork":false,"pushed_at":"2025-09-21T18:41:47.000Z","size":351,"stargazers_count":37,"open_issues_count":3,"forks_count":10,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-10-11T01:23:24.159Z","etag":null,"topics":["gleam","gleam-community","gleam-lang","mathematics","maths"],"latest_commit_sha":null,"homepage":"","language":"Gleam","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gleam-community.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-12-21T18:27:56.000Z","updated_at":"2025-09-28T21:19:40.000Z","dependencies_parsed_at":"2024-01-23T14:41:50.023Z","dependency_job_id":"cce81187-1a71-47a1-8806-0299f1c3a160","html_url":"https://github.com/gleam-community/maths","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/gleam-community/maths","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gleam-community%2Fmaths","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gleam-community%2Fmaths/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gleam-community%2Fmaths/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gleam-community%2Fmaths/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gleam-community","download_url":"https://codeload.github.com/gleam-community/maths/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gleam-community%2Fmaths/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28426138,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T16:38:47.836Z","status":"ssl_error","status_checked_at":"2026-01-14T16:34:59.695Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gleam","gleam-community","gleam-lang","mathematics","maths"],"created_at":"2024-08-03T04:00:58.835Z","updated_at":"2026-01-14T16:40:48.122Z","avatar_url":"https://github.com/gleam-community.png","language":"Gleam","funding_links":[],"categories":["Packages","Gleam"],"sub_categories":["Numbers"],"readme":"# gleam-community/maths\n\n[![Package Version](https://img.shields.io/hexpm/v/gleam_community_maths)](https://hex.pm/packages/gleam_community_maths)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/gleam_community_maths/)\n\nA basic mathematics library that contains some of the most fundamental mathematics functions and utilities.\n\nThe library supports both targets: Erlang and JavaScript.\n\n## Quickstart\n\n```gleam\nimport gleam/float\nimport gleam/list\nimport gleam/yielder\nimport gleam_community/maths\nimport gleeunit/should\n\npub fn example() {\n  // Evaluate the sine function\n  let result = maths.sin(maths.pi())\n  // Set the relative and absolute tolerance\n  let assert Ok(absolute_tol) = float.power(10.0, -6.0)\n  let relative_tol = 0.0\n  // Check that the value is very close to 0.0\n  // That is, if 'result' is within +/- 10^(-6)\n  maths.is_close(result, 0.0, relative_tol, absolute_tol)\n  |\u003e should.be_true()\n\n  // Find the greatest common divisor\n  maths.gcd(54, 24)\n  |\u003e should.equal(6)\n\n  // Determine if 999983 is a prime number\n  maths.is_prime(999_983)\n  |\u003e should.equal(True)\n\n  // Find the minimum and maximum of a list\n  maths.extrema([10.0, 3.0, 50.0, 20.0, 3.0], float.compare)\n  |\u003e should.equal(Ok(#(3.0, 50.0)))\n\n  // Determine if a number is fractional\n  maths.is_fractional(0.3333)\n  |\u003e should.equal(True)\n\n  // Generate all k = 2 combinations of [1, 2, 3]\n  let assert Ok(combinations) = maths.list_combination([1, 2, 3], 2)\n  combinations\n  |\u003e yielder.to_list()\n  |\u003e should.equal([[1, 2], [1, 3], [2, 3]])\n\n  // Compute the Cosine Similarity between two (orthogonal) \"vectors\"\n  maths.cosine_similarity([#(-1.0, 1.0), #(1.0, 1.0), #(0.0, -1.0)])\n  |\u003e should.equal(Ok(0.0))\n\n  // Generate a list of 3 logarithmically-spaced points over a specified \n  // interval, i.e., [10^1, 10^3]\n  let assert Ok(logspace) = maths.logarithmic_space(1.0, 3.0, 3, True, 10.0)\n  let pairs = logspace |\u003e list.zip([10.0, 100.0, 1000.0])\n  pairs\n  |\u003e list.all(fn(x) { x.0 == x.1 })\n  |\u003e should.be_true()\n}\n\n```\n\n## Installation\n\n`gleam_community` packages are published to [hex.pm](https://hex.pm/packages/gleam_community_maths)\nwith the prefix `gleam_community_`. You can add them to your Gleam projects directly:\n\n```sh\ngleam add gleam_community_maths\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgleam-community%2Fmaths","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgleam-community%2Fmaths","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgleam-community%2Fmaths/lists"}