2011-08-01 13:41:19 -05:00
|
|
|
// xfail-pretty
|
|
|
|
|
2011-07-21 18:47:47 -05:00
|
|
|
fn main() {
|
2011-07-27 19:36:37 -05:00
|
|
|
#macro([#zip_or_unzip[[x, ...], [y, ...]], [[x, y], ...]],
|
|
|
|
[#zip_or_unzip[[xx, yy], ...], [[xx, ...], [yy, ...]]]);
|
2011-07-21 18:47:47 -05:00
|
|
|
|
|
|
|
|
2011-07-27 19:36:37 -05:00
|
|
|
assert (#zip_or_unzip[[1, 2, 3, 4], [5, 6, 7, 8]] ==
|
2011-07-27 07:19:39 -05:00
|
|
|
[[1, 5], [2, 6], [3, 7], [4, 8]]);
|
2011-07-27 19:36:37 -05:00
|
|
|
assert (#zip_or_unzip[[1, 5], [2, 6], [3, 7], [4, 8]] ==
|
2011-07-27 07:19:39 -05:00
|
|
|
[[1, 2, 3, 4], [5, 6, 7, 8]]);
|
2011-07-21 18:47:47 -05:00
|
|
|
|
|
|
|
|
2011-07-27 19:36:37 -05:00
|
|
|
#macro([#nested[[[x, ...], ...], [[y, ...], ...]],
|
2011-07-21 18:47:47 -05:00
|
|
|
[[[x, y], ...], ...]]);
|
2011-07-27 19:36:37 -05:00
|
|
|
assert (#nested[[[1, 2, 3, 4, 5], [7, 8, 9, 10, 11, 12]],
|
|
|
|
[[-1, -2, -3, -4, -5], [-7, -8, -9, -10, -11, -12]]] ==
|
2011-07-27 07:19:39 -05:00
|
|
|
[[[1, -1], [2, -2], [3, -3], [4, -4], [5, -5]],
|
|
|
|
[[7, -7], [8, -8], [9, -9], [10, -10], [11, -11],
|
|
|
|
[12, -12]]]);
|
2011-07-21 18:47:47 -05:00
|
|
|
|
2011-07-27 19:36:37 -05:00
|
|
|
#macro([#dup[y, [x, ...]], [[y, x], ...]]);
|
2011-07-21 18:47:47 -05:00
|
|
|
|
2011-07-27 19:36:37 -05:00
|
|
|
assert (#dup[1, [1, 2, 3, 4]] == [[1, 1], [1, 2], [1, 3], [1, 4]]);
|
2011-07-21 18:47:47 -05:00
|
|
|
|
|
|
|
|
2011-07-27 19:36:37 -05:00
|
|
|
#macro([#lambda[x, #<t>, body, #<s>],
|
2011-07-27 07:19:39 -05:00
|
|
|
{
|
|
|
|
fn result(x: t) -> s { ret body }
|
|
|
|
result
|
|
|
|
}]);
|
2011-07-26 12:53:14 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
|
2011-07-27 19:36:37 -05:00
|
|
|
assert ((#lambda[i, #<uint>, i + 4u, #<uint>])(12u) == 16u)
|
2011-07-21 18:47:47 -05:00
|
|
|
|
|
|
|
}
|