#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

#758 in Command line utilities

Download history 14/week @ 2024-07-22 18/week @ 2024-08-26 7/week @ 2024-09-02 5/week @ 2024-09-09 15/week @ 2024-09-16 11/week @ 2024-09-23 31/week @ 2024-09-30 3/week @ 2024-10-07

61 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
~72K SLoC