Skip to content

Instantly share code, notes, and snippets.

@masak
Created February 12, 2012 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masak/1809356 to your computer and use it in GitHub Desktop.
Save masak/1809356 to your computer and use it in GitHub Desktop.
Cool use for a macro: meta for

Instead of...

for 1..10 -> $i {
    for 1..^$i -> $j {
        for 1..^$j -> $k {
            ...
        }
    }
}

How about this?

meta for 1..10 -> $i, 1..^$i -> $j, 1..^$j -> $k {
    ...
}

Or, if the number of for levels might vary,

constant $LEVELS = ...;
meta for 1..10, { 1..$^previous } xx $LEVELS {
    ...
}

I have no idea if the above can be made to work, but I'm eager to find out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment