| Crates.io | clair |
| lib.rs | clair |
| version | 0.1.0 |
| created_at | 2025-02-11 03:24:21.574017+00 |
| updated_at | 2025-02-11 03:24:21.574017+00 |
| description | Command-Line Arithmetic in Rust |
| homepage | |
| repository | https://github.com/hanslovsky/clair |
| max_upload_size | |
| id | 1550949 |
| size | 19,451 |
CLAIR is a small personal project for exploring the Rust programming language.
It implements arithmetic operations on lines of string (currently only stdin, but support for files as input is planned).
This is inspired by using awk for command line arithmetics.
cargo build [--release]
cargo run [--release] --bin={count,mean,product,sum} [</path/to/file/as/stdin] [--help]
or directly form target:
./target/release/{count,mean,product,sum}
$ ./target/release/count < Cargo.toml
24
# Reference:
$ wc -l Cargo.toml
24 Cargo.toml
$ shuf -i 1-100 | ./target/release/mean
50.5
# Reference:
$ shuf -i 1-100 | awk '{x += $1} END {print(x/100)}'
50.5
$ shuf -i 1-6 | ./target/release/product
720
# Reference:
$ shuf -i 1-6 | awk 'BEGIN {x=1} {x *= $1} END {print(x)}'
720
$ shuf -i 1-100 | ./target/release/sum
5050
# Reference:
$ shuf -i 1-100 | awk '{x += $1} END {print(x)}'
5050