Skip to content

Instantly share code, notes, and snippets.

@sarahzrf
Created February 1, 2018 22:16
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 sarahzrf/7ca53a57d6a0d655c871f04c5ead2aa5 to your computer and use it in GitHub Desktop.
Save sarahzrf/7ca53a57d6a0d655c871f04c5ead2aa5 to your computer and use it in GitHub Desktop.
const warn = @import("std").debug.warn;
fn Arr(comptime len: i32, comptime T: type) type {
if (len <= 0) {
return void;
} else {
var t = Arr(len - 1, T);
return struct {head: T, tail: t};
}
}
fn foo(comptime len: i32, a: Arr(len, i32)) %i32 {
return 3;
}
test "foo" {
warn("{}\n", foo(0, Arr(0, i32) {}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment