a super fast scientific calculator with dimensional analysis support written in Rust 🦀

Overview

larvae

larvae

a super fast scientific calculator with dimensional analysis support written in Rust 🦀 🐛

heavily inspired from insect

Usage:

Command mode:

$ larvae '1 * 1.123 kilometer ^ 2 / s + 100 s ^ -1 m * m + 10 km ^ 2 / s - 0 m ^ 2 / s -> m ^ 3 / m / s'
11123100 m^2  s^-1

Interactive mode:

$ larvae
>>> 1 * 1.123 kilometer ^ 2 / s + 100 s ^ -1 m * m + 10 km ^ 2 / s - 0 m ^ 2 / s -> m ^ 3 / m / s
11123100 m^2  s^-1
>>>

Why re-write insect in Rust?

  1. I thought it'd be fun
  2. Maybe I'd learn something cool like Earley parsing
  3. Maybe with a little more work, it'll even be as useful as insect someday
  4. It's super fast. It's like 2 orders of magnitude faster than insect in its current state (albeit it's still lacking some features):
$ hyperfine \
    'insect "e / e * log ( 10 ) * pi / pi * sqrt ( 1 ) ! % 2 * 1.123 kilometer ^ 2 / s + 100 s ^ -1 m * m + 10 km ^ 2 / s - 0 m ^ 2 / s -> m ^ 3 / m / s"' \
    'larvae "e / e * log ( 10 ) * pi / pi * sqrt ( 1 ) ! % 2 * 1.123 kilometer ^ 2 / s + 100 s ^ -1 m * m + 10 km ^ 2 / s - 0 m ^ 2 / s -> m ^ 3 / m / s"'
Benchmark 1: insect "e / e * log ( 10 ) * pi / pi * sqrt ( 1 ) ! % 2 * 1.123 kilometer ^ 2 / s + 100 s ^ -1 m * m + 10 km ^ 2 / s - 0 m ^ 2 / s -> m ^ 3 / m / s"
  Time (mean ± σ):     307.8 ms ±   4.4 ms    [User: 384.5 ms, System: 29.0 ms]
  Range (min … max):   301.2 ms … 314.0 ms    10 runs

Benchmark 2: larvae "e / e * log ( 10 ) * pi / pi * sqrt ( 1 ) ! % 2 * 1.123 kilometer ^ 2 / s + 100 s ^ -1 m * m + 10 km ^ 2 / s - 0 m ^ 2 / s -> m ^ 3 / m / s"
  Time (mean ± σ):       1.9 ms ±   0.7 ms    [User: 1.7 ms, System: 1.3 ms]
  Range (min … max):     0.6 ms …   4.3 ms    489 runs

  Warning: Command took less than 5 ms to complete. Results might be inaccurate.

Summary
  'larvae "e / e * log ( 10 ) * pi / pi * sqrt ( 1 ) ! % 2 * 1.123 kilometer ^ 2 / s + 100 s ^ -1 m * m + 10 km ^ 2 / s - 0 m ^ 2 / s -> m ^ 3 / m / s"' ran
  160.53 ± 57.94 times faster than 'insect "e / e * log ( 10 ) * pi / pi * sqrt ( 1 ) ! % 2 * 1.123 kilometer ^ 2 / s + 100 s ^ -1 m * m + 10 km ^ 2 / s - 0 m ^ 2 / s -> m ^ 3 / m / s"'

Features

  • Basic arithmetic (dimensionless numbers)

    • +, -,
    • *, /
    • ^
    • Other mathematical functions
      • %
      • !
      • sqrt
      • pi
      • exp
      • log
  • Dimensional analysis

    • Dimensional analysis arithmetic
    • Basic units
      • Length
      • Mass
      • Time
    • Compound units
      • Force
  • Cli

    • Basic functionality (currently only works when tokens are separated by white space)
    • Equation parsing w/ recognition of dimensioned quantities
    • "Smart" Tokenisation of equation strings containing functions, units, values, etc.
    • Colors
    • Fancy characters (i.e. s⁻³·m⁻², Ω)
  • Future goals

    • Support algebraic solving of variables w/ units
You might also like...
A tiny service that downloads files over HTTP links, with resume and restart support.
A tiny service that downloads files over HTTP links, with resume and restart support.

Http Drogue Http Drogue is a tiny service that downloads files over HTTP from links you provide. It can restart and resume interrupted downloads. Http

Extended Kinect support for Garry's Mod
Extended Kinect support for Garry's Mod

🦵 gmcl_rekinect This is a reimplementation of Kinect support for Garry's Mod, allowing you to do stuff like this on more platforms. Features Support

Blazing fast, memory safe & modern Linux package manager written in Rust.

paket Blazing fast, memory safe & modern Linux package manager written in Rust. Roadmap Version: 0.1 Paket.toml file parsing. (#1, #2) CLI handling (p

A fast uuid generator in Python using Rust

ruuid A fast UUID generator for Python built using Rust. Its a simple wrapper on top of Rust's UUID crate. How to use? Installation: pip3 install ruui

fast rust implementation of online nonnegative matrix factorization as laid out in the paper "detect and track latent factors with online nonnegative matrix factorization"

ONMF status: early work in progress. still figuring this out. code still somewhat messy. api still in flux. fast rust implementation of online nonnega

A fast lean and clean modern constraint programming solver implementation (in rust)

MaxiCP-rs This project aims at implementing a fast, and clean constraint programming solver with a focus on correctness, simplicity, maintainability a

Fast and simple datetime, date, time and duration parsing for rust.

speedate Fast and simple datetime, date, time and duration parsing for rust. speedate is a lax† RFC 3339 date and time parser, in other words, it pars

A traditional web forum built in Rust with modern technology to be fast, secure, scalable, and stable.

Volksforo A traditional web forum built in Rust with modern technology to be fast, secure, scalable, and stable. Stack Rust actix-web askama ScyllaDB

A fast rendezvous in rust where data can optionally be swapped between the two threads.

rendezvous_swap A rendezvous is an execution barrier between a pair of threads, but this crate also provides the option of swapping data at the synchr

Owner
John McAvoy
John McAvoy
`N` dimensional cubic chunks crate

Hypercube Todo create OffsetShape<S: Shape, const D: usize> a Shape offset by some amount Api positions(self) -> OffsetPositions<Self> create OffsetPo

null 3 Jan 15, 2023
Now, the Host is Mine! - Super Fast Sub-domain Takeover Detection!

NtH1M - Super Fast Sub-domain Takeover Detection Notice This is a sad notice that our Internet Hero (@TheBinitGhimire) had recent demise on 26th of Ju

Captain Nick Lucifer* 5 Nov 5, 2022
A rust version of "the super tiny compiler"

The (Rust) super tiny compiler This project is a rust version of the super tiny compiler (the original one (JS) was created by Jamie Kyle). The output

Eduardo Stuart 6 Dec 25, 2022
A super simple dialogue system for Rust.

?? Dialogos A super simple dialogue system for Rust. It's nothing special, but that's the point! It's something that just works. This library is ideal

null 3 Sep 19, 2022
Super-simple, fully Rust powered "memory" (doc store + semantic search) for LLM projects, semantic search, etc.

memex Super simple "memory" for LLM projects, semantic search, etc. Running the service Note that if you're running on Apple silicon (M1/M2/etc.), it'

Spyglass Search 15 Jun 19, 2023
Incremental Program Analysis Framework

IncA Overview IncA is a program analysis framework. It comes with a DSL for the definition of program analyses and the runtime system evaluates progra

Tamas Szabo 70 Nov 24, 2022
A Rust implementation of generic prefix tree (trie) map with wildcard capture support

prefix_tree_map A Rust implementation of generic prefix tree (trie) map with wildcard capture support. Design Trie is a good data structure for storin

EAimTY 3 Dec 6, 2022
Rust Library for controlling divoom devices that support REST APIs, such as pixoo-64.

Divoom Rust Library for controlling divoom devices that support REST APIs, such as pixoo-64 (and from how divoom's api/doc organizes, maybe more in th

Riff 16 Dec 23, 2022
Rust based magic-string with source map chains support

enhanced-magic-string Rust implementation of https://www.npmjs.com/package/magic-string with original sourcemap chain support. license. This project i

Farm 3 Nov 5, 2023
Support SIMD low-memory overhead and high-performance adaptive radix tree.

Artful Artful is an adaptive radix tree library for Rust. At a high-level, it's like a BTreeMap. It is based on the implementation of paper, see The A

future 3 Sep 7, 2022