Need a powerful and simple library to work with arithmetic progressions in Rust? You should definitively try out ariprog!

Overview

Ariprog

GitHub top language Crates.io Version GitHub's license GitHub last commit (branch)

I had a test (03/2024) on arithmetic progressions, so I decided to create a library to study math. Taking advantage of the fact that I was studying Rust and APs, I created this library.

The objetive of ariprog is to solve the main problems around APs. Here's a list of what it's capable of.

  • Get common difference (d)
  • Get nth term (an)
  • Get first term (a)
  • Get how many terms in the AP (n)
  • Interpolate/insert arithmetic means
  • Get common difference and first term (d, a)

In the API section, you'll see the corresponding functions and how to use them.

🛠 Usage

Installation

First, create a new Rust project or open an existing one

cargo new testing-ariprog
cd testing-ariprog

# or
cd existing-project

Then, add ariprog as a dependency

cargo add ariprog

As an alternative, you can add the following line in your Cargo.toml (dependencies section)

ariprog = "0.1.4"

Getting started

use ariprog::{
    common_difference,
    nth_term
};

fn main() {
    let common_diff = common_difference(6.0, 2.0); // expected 4.0

    println!(
        "The common difference in the AP [2.0, 6.0, 10.0, 14.0] is {}",
        common_diff
    );

    println!(
        "The seventeenth term of the AP [2.0, 6.0, 10.0, 14.0, ...] is {}",
        nth_term(2.0, common_diff, 17.0)
    ); // expected 66.0
}

API

First things first, after adding ariprog in your project, import it.

use ariprog;
  • Get common difference (d): ariprog::common_difference
  • Get nth term (an): ariprog::nth_term
  • Get first term (a): ariprog::first_term
  • Insert/interpolate arithmetic means: ariprog::insert_arithmetic_means
  • Get how many terms in the AP (n): ariprog::how_many_terms
  • Get common difference and first term (d, a): ariprog::common_difference_and_first_term

All of these functions have their own documentation. See in docs.rs or in your IDE.

💖 Contributing

Feel free to fork it, make a change and open a pull request. Same for issues, suggest an API change, an improvement, a feature or report a bug.

How to contribute

  1. Fork this repository
  2. Clone your fork on your machine
  3. Make your changes, commit and push these
  4. Open a pull request (write a descriptive message about what you changed)

🧪 Testing

To test ariprog, with the project in your machine, run cargo test.

You should create tests in tests/unit_test.rs, however if you think that your tests should be in other module, do it and explain why in the PR.

📝 License

This project is licensed under the MIT License - See the LICENSE for more information.


Made with ❤ and 🦀 by Kauê Fraga Rodrigues.

You might also like...
Neovim Configuration Manager (Swap/Backup/Try Configurations Easily)
Neovim Configuration Manager (Swap/Backup/Try Configurations Easily)

ncm-rs Neovim Configuration Manager (Swap/Backup/Try Configurations Easily) I created this package because I wanted to try out Lazyvim (which is why i

Simple yet powerful multi-line text editor widget for tui-rs and ratatui
Simple yet powerful multi-line text editor widget for tui-rs and ratatui

tui-textarea tui-textarea is a simple yet powerful text editor widget like textarea in HTML for tui-rs and ratatui. Multi-line text editor can be ea

Estratto is a powerful and user-friendly Rust library designed for extracting rich audio features from digital audio signals.
Estratto is a powerful and user-friendly Rust library designed for extracting rich audio features from digital audio signals.

estratto 〜 An Audio Feature Extraction Library estratto is a powerful and user-friendly Rust library designed for extracting rich audio features from

🐎 Just a simple cross-platform neofetch for all the bronies out there.

⚠️ (WIP) This project is not ready for any serious use right now. A cross-platform command-line interface (CLI) tool written in Rust to display system

A simple cli tool for generating quotes in your terminal from Kanye west. Start the day out strong.
A simple cli tool for generating quotes in your terminal from Kanye west. Start the day out strong.

Kanyey A simple cli tool for generating quotes in your terminal from Kanye West. Install Just do cargo install kanyey and be blessed. Bonus: throw it

EmbedAnything is a powerful python library designed to streamline the creation and management of embedding pipelines
EmbedAnything is a powerful python library designed to streamline the creation and management of embedding pipelines

EmbedAnything is a powerful python library designed to streamline the creation and management of embedding pipelines. Built in Rust with no heavy dependencies.

🪞 Powerful reflection library for Rust

🪞 mirror-mirror Powerful reflection library for Rust 🚨 Warning 🚨 This library is still experimental and should not be used for anything serious, ye

A tool to easily work with timezone lookups via a binary, a library, or a server.
A tool to easily work with timezone lookups via a binary, a library, or a server.

rtz A self-contained geo lookup library / binary / server for Rust / JS (via WASM) (free server) using data from the Natural Earth and OpenStreetMap d

A lightweight but incredibly powerful and feature-rich BitTorrent tracker. Supports UDP + HTTP(S) and a private tracker mode.

Torrust Tracker Project Description Torrust Tracker is a lightweight but incredibly powerful and feature-rich BitTorrent tracker made using Rust. Feat

Owner
Kauê Fraga Rodrigues
Software Developer
Kauê Fraga Rodrigues
Logging for text that should stay in the same place in a console.

console_static_text Crate for logging text that should stay in the same place in a console. This measures words to handle wrapping and has some consol

David Sherret 8 Dec 25, 2022
Display a random Shiba from your terminal whenever you feel the need to. Because why not?

Shiba CLI Command-line interface (CLI) to display a random Shiba Inu whenever needed, by just running shiba on your terminal. How To Use • How Does It

null 17 Sep 25, 2022
Dura - You shouldn't ever lose your work if you're using Git

Dura Dura is a background process that watches your Git repositories and commits your uncommitted changes without impacting HEAD, the current branch,

Tim Kellogg 4.1k Jan 8, 2023
The library for those who need a little extra from their windows. ™

WinEx The library for those who need a little extra from their windows. ™ WinEx - Short for Window Extended - is a library whose goal is to implement

Matheus Branco Borella 2 Mar 27, 2022
Rust crate for Ok-wrapping and try blocks

tryvial A small crate for Ok-wrapping and try blocks. This is compatible with Result, Option, and any type implementing the unstable std::ops::Try tra

null 11 Jan 25, 2023
try to find the correct word with only first letter and unknown letter count.

MOTUS Current dictionaries are provided in french and can contain some words not included in the official Motus dictionary. Additionally, dictionaries

Alexandre 6 Apr 11, 2022
mn is my project to learn rust, I will try to build a markdown editor

med is a markdown editor This is my project to learn rust programming language, I will try to build a powerful markdown editor. Highlight: Support Vim

Skoo Wu 7 Dec 29, 2022
My try at Advent of Code 2022 in Rust.

Advent of Code 2022 My solutions to Advent of Code 2022, written in Rust. I love seeing the variety of solution other people come up with, so I decide

Luke Taylor 6 Dec 15, 2022
Expand your possibilities with the Try ? Operator

Expand your possibilities with the Try ? Operator Have you ever found yourself writing a function which may return early based on some condition? fn m

EC 1 Feb 1, 2022
Errable is an Option with inverted Try-semantics.

Fallible Fallible is an Option with inverted Try-semantics. What this means is that using the ? operator on a Fallible<E> will exit early if an error

Mathias Pius 18 Jan 23, 2023