Created
December 3, 2018 00:22
-
-
Save jswrenn/8aea0aec3c635cb8942a2ae8d3d8fe6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! pairs{ | |
() => {}; | |
($h : expr, $($t : expr,)*) => | |
{ | |
println!("({},{})", $h, $h); | |
$(println!("({},{})", $h, $t);)* | |
$(println!("({},{})", $t, $h);)* | |
pairs!{$($t,)*} | |
} | |
} | |
macro_rules! pairs{ | |
({} { $($r: expr),* }) => {}; | |
({$lh : expr, $($lt : expr,)*} { $($r: expr),* }) => | |
{ | |
$(println!("({},{})", $lh, $r);)* | |
pairs!{{$($lt,)*} {$($r),*}} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment