#sampling #random #permutations #iterable #shuffle #line #text

app shuf-rs

Generate random permutations of an iterable with reservior sampling

2 unstable releases

0.2.0 Jul 19, 2024
0.1.0 Jul 7, 2021

#590 in Command line utilities

44 downloads per month

MIT license

7KB
131 lines

shuf-rs

Shuffle lines of text with reservior sampling.

Build

cargo build --release

The resulting binary is found under target/release/shuf.

Usage

USAGE:
    shuf [OPTIONS] [path]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -n, --head-count=COUNT <num>    Number of lines to read

ARGS:
    <path>    The path to the file to read

mod shuf

src/shuf.rs contains a reusable implementation of reservior sampling, that works on any iterable.

Dependencies

~4MB
~71K SLoC