Skip to content

Instantly share code, notes, and snippets.

@crazymonkyyy
Created February 21, 2026 23:07
Show Gist options
  • Select an option

  • Save crazymonkyyy/7369d1dd91d73d9274b554816f9f4545 to your computer and use it in GitHub Desktop.

Select an option

Save crazymonkyyy/7369d1dd91d73d9274b554816f9f4545 to your computer and use it in GitHub Desktop.
#!opend test app.d
--- app.d
import std;
struct rangewrap(R...){
R r;
auto opBinary(string op:"*",R2)(R2 r2){
return rangewrap!(R,R2)(r,r2);
}
void opDispatch(string __s__,T...)(T args){
foreach(tuple;cartesianProduct(r)){
mixin(__s__~"(tuple,args);");
}}
}
unittest{
(rangewrap!()() * [1,2,3] * "abc" * [true,false]).writeln;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment