Skip to content

Instantly share code, notes, and snippets.

@proman21
proman21 / subsets.rs
Created July 31, 2017 08:37
Recursive Impl of a Subsets function
fn subsets<T>(set: &[T]) -> Vec<Vec<&T>> {
if let Some((first, rest)) = set.split_first() {
let mut subsets = subsets(rest);
for mut set in subsets.clone() {
set.insert(0, first.clone());
subsets.push(set);
}
subsets
} else {
vec![vec![]]

Keybase proof

I hereby claim:

  • I am proman21 on github.
  • I am synthsym (https://keybase.io/synthsym) on keybase.
  • I have a public key ASCr9tDfH8iiHmyHq2M5WSAQigjOsYZF8e-f853sa_kXBwo

To claim this, I am signing this object: