Skip to content

Instantly share code, notes, and snippets.

@relsqui
Created December 10, 2015 03:32
Show Gist options
  • Save relsqui/95d24b02aae58144b023 to your computer and use it in GitHub Desktop.
Save relsqui/95d24b02aae58144b023 to your computer and use it in GitHub Desktop.
> iter = Utils::iterate((string[]) {"foo", "bar", "baz"});
> string a;
> while (iter(&a)) {
+ printf("%s\n", a);
+ }
foo
bar
baz
namespace Utils {
public bool(*poly) function iterate(poly[] list) {
return (bool func(*poly value) {
static int i = 0;
if (i < dim(list)) {
*value = list[i];
i++;
return true;
} else {
return false;
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment