Giter VIP home page Giter VIP logo

calc's Introduction

calc

Build Status crates.io

calc is a Rust library for tokenizing and evaluating arithmetic expressions with a command line application of the same name included.

NOTE: The name of the project, binary, and library are calc but the package name is calculate. This will remain depending on if this project can acquire the calc crate which is currently being squatted on.

Usage

As a Library

Add calc as a dependency in your Cargo.toml:

[dependencies]
calculate = "0.1.*"

Then make use of the library functions:

extern crate calc;

use calc::eval;
use std::io::{self, BufRead, stdout, stdin, Write};

fn main() {
    let stdout = stdout();
    let mut stdout = stdout.lock();
    let stdin = stdin();
    for line in stdin.lock().lines() {
        match line.unwrap().trim() {
            "" => (),
            "exit" => break,
            s => writeln!(stdout, "{}", eval(s)).unwrap(),
        }
    }
}

As an Executable

$ cargo install calculate
...
$ calc

calc's People

Contributors

hgoldstein avatar mgmoens avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.