Fits best into algorithm module I guess. These are the most general
ways, an iterator could easily be implemented from this. Same algorithm
as in Rust: http://web.mit.edu/rust-lang_v0.11/doc/src/collections/var/tmp/alexp/rust/rust-0.11.0/src/libcollections/slice.rs.html#644