Kalker (or "kalk") is a calculator program/website that supports user-defined variables, functions, derivation, and integration

Overview

Kalker (or "kalk") is a calculator program/website that supports user-defined variables, functions, derivation, and integration. It runs on Windows, macOS, Linux, Android, and in web browsers (with WebAssembly).

Crates.io npm GitHub Docs.rs Build status

Kanban | Website - Try it out here!

Features

  • Operators: +, -, *, /, !
  • Groups: (), [], ⌈ceil⌉, ⌊floor⌋
  • Vectors: (x, y, z, ...)
  • Matrices: [x, y, z; a, b, c; ...]
  • Pre-defined functions and constants
  • User-defined functions and variables. f(x, y) = xy, x = 5
  • Root finding using Newton's method (eg. x^2 = 64). Note: estimation and limited to one root
  • Derivative of functions (derivatives of noisy functions or of higher order can be a bit inaccurate). f'(2), sin'(-pi)
  • Integration. ∫(0, pi, sin(x) dx) or ∫(0, π, sin(x) dx), maybe sometimes be slightly off
  • Understands fairly ambiguous syntax. Eg. 2sin50 + 2xy
  • Syntax highlighting
  • Special-symbol completion on tab. Eg. write sqrt and press tab. It will be turned into
  • Sum function: sum(start, to, expression) Eg. sum(1, 3, 2n+1) is the same as 2*1+1 + 2*2+1 + 2*3+1 = 15
  • Piecewise functions: f(x) = { f(x + 1) if x <= 1; x otherwise }, pressing enter before typing the final } will make a new line without submitting
  • Load a file including predefined functions and constants. For example, if you're going to use kalker for physics, you load up your file with physics functions/constants when starting kalker. This is done either using the -i file flag or by putting files in a certain directory and then doing load filename inside kalker. More about files here
  • Different number bases: Either with a format like 0b1101, 0o5.3, 0xff or a format like 1101_2. The latter does not support letters, as they would be interpreted as variables
  • Misc: separate expressions by a semicolon to write them on the same line, use the ans variable to get the value of the previously calculated expression

Installation

Package managers

macOS

brew install kalker

Arch Linux

kalker in the AUR, eg. yay -S kalker

Nix/NixOS

Kalker is available through nixpkgs. The most up to date version is also available as a flake.

NetBSD

Kalker is available from the official repositories, pkgin install kalker

Binaries

Pre-compiled binaries for Linux, Windows, and macOS (64-bit) are available in the releases page.

Compiling

Minimum rust version: v1.36.0. Make sure you have diffutils gcc make and m4 installed. If you use windows: follow the instructions here (don't forget to install mingw-w64-x86_64-rust in MSYS2).

Cargo

Run cargo install kalker

Manually

  1. Go into the cli directory.
  2. Run cargo build --release
  3. Grab the binary from targets/release

Donation

Kalker is completely free and open source. If you wish to support further development of Kalker and contribute towards it one day getting published on the Google Play Store, you can do so here: PayPal

Libraries

There are currently three different libraries related to kalker.

  • kalk: The Rust crate that powers it all.
  • @paddim8/kalk: JavaScript bindings for kalk. This lets you use it in the browser thanks to WebAssembly.
  • @paddim8/kalk-component: A web component that runs @paddim8/kalk, which let's you use kalk in the browser with a command line-like interface.

Syntax

A more complete reference can be found on the website.

Functions

Defining: name(parameter1, parameter2, ...) = expression
Example: $ f(x) = 2x+3 $

Using: name(argument1, argument2)
Example: $ f(2) $

Variables

Defining: name = expression
Example: $ x = 3 $

Using: name
Example: $ x $

Contributing

kalk and cli (Rust)

After making changes to the kalk library (in kalk/), you can easily try them out by going to the root of the project directory, and doing cargo run. This will start kalker (cli), with the new changes. If you're using Windows, you will need to follow the instructions here, but also make sure to install mingw-w64-x86_64-rust in MSYS2.

All Rust code is expected to be formatted with `rustfmt

web (Svelte, TypeScript, Sass)

Run:

  1. npm install
  2. npm run dev - this will automatically re-compile the project when changes are made

mobile (Android)

Run:

  1. npm install
  2. npx cap sync
  3. Build the project using Android Studio, or Gradle directly.
Comments
  • Name collision with KDE Kalk

    Name collision with KDE Kalk

    KDE Kalk is also a calculator from the KDE project: https://github.com/KDE/kalk

    I understand it is different from this project? I installed "kalk" from the AUR and was surprised get a UI ... maybe you are still on time to rename? I know this hurts, but its unfortunate that we have two tools with the same functional scope with the same name :/

    opened by gabm 13
  • Add `gcd`/`lcm` functions

    Add `gcd`/`lcm` functions

    This PR adds the gcd and lcm functions.

    >> gcd(12, 18)
    6
    >> lcm(12, 18)
    36
    

    GCD is calculated with the modified Euclidean algorithm, and LCM is calculated with:

                 ⎛           ⎞
                 ⎜    ⎜a⎜     ⎟
    lcm(a, b) =  ⎜ ───────── ⎟ × ⎜b⎜
                 ⎜ gcd(a, b) ⎟
                 ⎝           ⎠
    
    opened by kiedtl 10
  • User defined constants

    User defined constants

    I'm using the windows binary an what I'm missing the most ATM is a way to define constants I use often so I don't have to define them as variables every session. I suppose it would mean having at least an external config file... which I would prefer to be human-readable/editable, maybe some json?

    opened by bokeron2020 10
  • please remove outdated patch

    please remove outdated patch

    Patching of Cargo.toml is no longer needed. The relevant commit on gmp-mpfr-sys has been merged and is part of the 1.4.8 release. I've removed the patch locally and regenerated Cargo.lock but for some reason I'm not able to push the changes and create a PR. It seems like some more changes (nix flakes?) are needed to address conflicts flagged by git when pushing, hence my request here.

    Thanks!

    opened by 0323pin 6
  • Add piecewise functions

    Add piecewise functions

    For example image could be written as

    f(x) = {-x-x if x≤-3; x+3 if -3≤x≤0; 3-2x if 0≤x≤3; 0.5x-4.5 if 3≤x}
    

    or:

    f(x) = {x≤-3: -x-x; -3≤x≤0: x+3; 0≤x≤3: 3-2x; 3≤x: 0.5x-4.5}
    
    opened by abrudz 6
  • Installation Fail

    Installation Fail

    Running cargo install kalk_cli is failing for me with:

      Updating crates.io index
      Downloaded kalk_cli v0.1.10
      Downloaded 1 crates (8.4 KB) in 0.94s
      Installing kalk_cli v0.1.10
    error: failed to compile `kalk_cli v0.1.10`, intermediate artifacts can be found at `/tmp/cargo-installrPOC9T`
    
    Caused by:
      failed to parse lock file at: /home/ewpratten/.cargo/registry/src/github.com-1ecc6299db9ec823/kalk_cli-0.1.10/Cargo.lock
    
    Caused by:
      invalid serialized PackageId for key `package.dependencies`
    

    cargo -V is outputting:

    cargo 1.35.0 (6f3e9c367 2019-04-04)
    
    opened by ewpratten 6
  • Exponentiation on the web interface

    Exponentiation on the web interface

    Exponentiation does not seem to work in the web interface (Firefox).

    As the web interface immediately converts the input into special symbols it is not possible to do inputs such as 2**3 as these get immediately turned into 2⋅⋅3, which then results in Unexpected token: 'Star'

    Also I am not able to input ^2 for some reason as the circumflex gets immediately deleted.

    The console version works fine.

    opened by MonaMayrhofer 5
  • Add Iverson Bracket

    Add Iverson Bracket

    An Iverson Bracket is simply a predicate in square brackets which evaluates to 0 if false or 1 if true. It is great for defining functions in multiple pieces, for example f(x)=x[x<0]+x^2[x>0]:

    image

    opened by abrudz 4
  • Consider using a more robust CLI arguments parser

    Consider using a more robust CLI arguments parser

    Currently when I run kalk help (out of habit) I get a weird error of Undefined variable: 'h'.. I think switching to a ready solution would greatly benefit future development.

    Something like Clap requires minimal setup while providing a lot of great features (like generating shell completions which are hard to maintain by hand). This will add to compile time though so it is worth thinking about it.

    I am willing to help with the transition.

    opened by shilangyu 4
  • Support for Permutations and Combinations calculation

    Support for Permutations and Combinations calculation

    Forgive me if I am missing it, but it seems like we do not have support permutations and combinations calculation, correct? Can someone confirm this?

    I realized this as I was using kalker in my school test. :)

    opened by hanani8 3
  • function application

    function application

    $ f(x) =  x^2
    $ f 2
    4
    $ g(x,y) = x^2y
    g 1 2
    Expected 2 arguments for function g, but got 1.
    

    Haskell-like function application would be very useful, is it meant to be supported only for one-param functions?

    opened by bieganski 3
  • Adding kalker to F-Droid

    Adding kalker to F-Droid

    It would be really nice if kalker was available through F-Droid. As far as I know, kalker fulfills almost all criteria to be accepted by F-Droid, except some structural requirement of having Metadata about the project in a certain location. It would be amazing if you could propose adding it.

    opened by R1yuu 1
  • Custom built-in functions

    Custom built-in functions

    I would like to define custom built in functions from Rust call-backs. This makes the functions more extendable as you have access to Rust's functionality like println! along with other Rust math libraries. Is this currently possible? If not I think this should be considered. It allows fore greater extendibility without the need of another parser.

    opened by NatanFreeman 8
  • Is there any way to retrieve variables from `Context`?

    Is there any way to retrieve variables from `Context`?

    I would like to retrieve all user defined variables from a Context but this doesn't seem like it's currently possible. Being able to delete them would be useful too.

    opened by NatanFreeman 2
  • Missing solutions for variable inference.

    Missing solutions for variable inference.

    When using eval to parse variable's to the power only positive values are considered.

    use kalk::parser;
    
    fn main() {
        let mut parser_context = parser::Context::new();
        let result = parser::eval(&mut parser_context, &"x^2=4")
            .unwrap()
            .unwrap();
    
        println!("{}", result);
    }
    

    Outputs:

    2

    This is missing the solution x=-2.

    opened by NatanFreeman 1
  • Trigonometric functions with degrees not convenient

    Trigonometric functions with degrees not convenient

    When I want to calculate sin(90deg) without brackets this is what I got:

    >> sin 90deg
    0.0156031853 rad
    

    which is actually:

    >> (sin 90)deg
    0.0156031853 rad
    

    Maybe the "deg" can have a higher order in calculation?

    By the way, If the function is provided with "degrees"

    >> sin (90deg)
    1 rad
    

    the "rad" after "sin" "cos" "tan" still exists. But these functions should "eat" the "rad".

    opened by chemPolonium 0
Releases(v2.0.1)
kindly is a simple Rust implementation of a set-user-ID-root program, similar to sudo but in a much reduced way.

kindly is a simple Rust implementation of a set-user-ID-root program, similar to sudo but in a much reduced way.

Vinícius Miguel 26 Dec 5, 2022
An example project demonstrating integration with Rust for the ESP32-S2 and ESP32-C3 microcontrollers.

Rust ESP32 Example An example project demonstrating integration with Rust for the ESP32-S2 and ESP32-C3 microcontrollers.

Espressif Systems 303 Jan 4, 2023
Egui integration for nannou

nannou_egui This is my egui integration for nannou. The purpose of this is to allow you to tune values for your generative art creations without requi

Alexandru Ene 28 Oct 12, 2022
A Rust proc-macro crate which derives functions to compile and parse back enums and structs to and from a bytecode representation

Bytecode A simple way to derive bytecode for you Enums and Structs. What is this This is a crate that provides a proc macro which will derive bytecode

null 4 Sep 3, 2022
`Debug` in rust, but only supports valid rust syntax and outputs nicely formatted using pretty-please

dbg-pls A Debug-like trait for rust that outputs properly formatted code Showcase Take the following code: let code = r#" [ "Hello, World!

Conrad Ludgate 12 Dec 22, 2022
Rust Keeper bots that run various functions, from liquidations, to orderbook cranks, and more.

The zo-keeper (pronounced "zoo keeper") repository runs large scale instructions that secure the 01 network, and allow it to operate in a fully decentralized manner.

Zero One Global Foundation 61 Dec 16, 2022
`grep` but with PEG patterns. Define grammars (e.g. `digit`), functions for matching. No more regex syntax!

PEG peggrep Example file demo_file: THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE. this line is the 1st lower case line in this file. This Line Ha

IchHabeKeineNamen 3 Apr 18, 2023
qn (quick note) is a simple, fast and user-friendly way to save notes 🦀⚙️

Quick Note qn Install This is currently for my personal use. I may push breaking changes at any time. If you want to use it, bring down the code and r

Code Smell 3 Jul 15, 2022
👁️ See through bad bots trying to lie about their user agents

Odd Eye Detect bad bots trying to disguise themselves as humans. Features HTTP2 connection fingerprints TLS signatures Canvas fingerprints How it work

Xetera 31 Dec 14, 2022
Telegram bot for searching in Arch User Repository ( AUR ); Implemented using rust.

AurSearchBot A Telegram Inline Search Bot Written in Rust Introduction Telegram Bot that can search AUR ( Arch User Repository ) in inline mode. This

AlenPaulVarghese 3 Feb 15, 2022
A small monitoring process that checks if kstars is active, if not it sends a request to notify a user via telegram that it crashed

Astro monitor A small monitoring process that checks if kstars is active, if not it sends a request to notify a user via telegram that it crashed Inst

Mattia Procopio 2 Jan 10, 2022
A rust program to try and detect some types of Hardware Keyloggers.

Hardware Keylogger Detection Warning: Certain Types of Hardware keyloggers can not be detected by this program, Passive Hardware Keyloggers are imposs

null 4 Dec 5, 2022
Rust library for program synthesis of string transformations from input-output examples 🔮

Synox implements program synthesis of string transformations from input-output examples. Perhaps the most well-known use of string program synthesis in end-user programs is the Flash Fill feature in Excel. These string transformations are learned from input-output examples.

Anish Athalye 21 Apr 27, 2022
osu-link is a program which links osu!stable beatmaps to osu!lazer's new store format, saving you disk space.

osu-link is a program which links osu!stable beatmaps to osu!lazer's new store format, saving you disk space.

LavaDesu 2 Nov 8, 2021
Solana Escrow Program

Environment Setup Install Rust from https://rustup.rs/ Install Solana from https://docs.solana.com/cli/install-solana-cli-tools#use-solanas-install-to

Nathan Ramli 0 Nov 12, 2021
A variation of the solana helloworld program example with a client written in Rust instead of Typescript

Simple Solana Smart Contract Example This repository demonstrates how to create and invoke a program on the Solana blockchain. In Solana the word prog

zeke 56 Dec 26, 2022
A realtime flight tracking program for our Software Engineering 300 class at ERAU

Flight Tracking ERAU SE300 Description Software that allows for weather and plane tracking to facilitate the user in looking at plane paths. Many peop

null 18 Sep 29, 2022
01 Solana program application interface.

01 abi The abi is a repository for interfacing with the 01 program either through a rust client or through CPIs from another Solana program. Program A

Zero One Global Foundation 19 Oct 16, 2022
Minimalistic solana minter program if you don't want to use Metaplex

Minimalistic solana minter program The objective of this repository is to be only a minimalistic template for NFTs projects on Solana, so you can buil

Gabriel 23 Sep 6, 2022