1 unstable release
0.1.0 | Nov 17, 2023 |
---|
#5 in #cartesian
12KB
201 lines
product_index
A tool for get the ND indicies of a grid from a 1D index.
Usage
arr1=($(seq 1 1 5))
arr2=($(seq 1 1 6))
N=12
# prints 2 0
product_index $N "${#arr1[@]}" "${#arr2[@]}"
# stores i1=2 i2=0
read -r i1 i2 <<< $(product_index $N "${#arr1[@]}" "${#arr2[@]}")
# Prints 3,1
echo "x,y = ${arr1[$i1]}, ${arr2[$i2]}"
Installation
To install from crates:
cargo install product_index
To install manually, clone the repo and use cargo install --path .
Step by step Manual Install
- If cargo is not installed, install the rust compilers:
(See https://www.rust-lang.org/tools/install for more options)curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Clone the repo:
git clone https://github.com/chappertron/product_index.git
cd
into the repo folder- Run the cargo install command:
cargo install --path .
You should now be able to access the product_index
binary from the command line.
Dependencies
~1.3–2MB
~37K SLoC