Skip to content

Instantly share code, notes, and snippets.

@brendanzab
Forked from anonymous/playground.rs
Last active September 27, 2015 04:41
Show Gist options
  • Save brendanzab/d6224000627aa66d624a to your computer and use it in GitHub Desktop.
Save brendanzab/d6224000627aa66d624a to your computer and use it in GitHub Desktop.
Shared via Rust Playground
fn main() {
swizzle_gen();
}
fn swizzle_gen() {
swizzle_gen0("x");
swizzle_gen0("y");
swizzle_gen0("z");
swizzle_gen0("w");
}
fn swizzle_gen0(c0: &str) {
println!("{}", c0);
swizzle_gen1(c0, "x");
swizzle_gen1(c0, "y");
swizzle_gen1(c0, "z");
swizzle_gen1(c0, "w");
}
fn swizzle_gen1(c0: &str, c1: &str) {
println!("{}{}", c0, c1);
swizzle_gen2(c0, c1, "x");
swizzle_gen2(c0, c1, "y");
swizzle_gen2(c0, c1, "z");
swizzle_gen2(c0, c1, "w");
}
fn swizzle_gen2(c0: &str, c1: &str, c2: &str) {
println!("{}{}{}", c0, c1, c2);
swizzle_gen3(c0, c1, c2, "x");
swizzle_gen3(c0, c1, c2, "y");
swizzle_gen3(c0, c1, c2, "z");
swizzle_gen3(c0, c1, c2, "w");
}
fn swizzle_gen3(c0: &str, c1: &str, c2: &str, c3: &str) {
println!("{}{}{}{}", c0, c1, c2, c3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment