// // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo // // The contents of this file are covered under the licence agreement in the // file "LICENCE" distributed with Cforall. // // tuplePolymorphism.c -- // // Author : Rob Schluntz // Created On : Tue Nov 16 10:38:00 2016 // Last Modified By : Rob Schluntz // Last Modified On : Tue Nov 16 10:39:18 2016 // Update Count : 2 // forall(otype T | { T ?+?(T, T); }) [T, T, T] ?+?([T, T, T] x, [T, T, T] y) { return [x.0+y.0, x.1+y.1, x.2+y.2]; } int main() { int x1 = 123, x3 = 456; double x2 = 999.123; int i1 = 111, i3 = 222; double i2 = 333; int d1 = 555, d3 = 444; double d2 = 666; [i1, i2, i3] = ([x1, (int)x2, x3]) + ([9, 2, 3]); [d1, d2, d3] = ([x1, x2, x3]) + ([9, 2, 3]); printf("%d %g %d\n", i1, i2, i3); printf("%d %g %d\n", d1, d2, d3); [double, double, double] zzz; zzz = [x1, x2, x3]; printf("%g %g %g\n", zzz); [x1, x2, x3] = zzz+zzz; printf("%d %g %d\n", x1, x2, x3); } forall(otype T) [T, T] foo([T, T] y) { [T, T] x; return x; } // Local Variables: // // tab-width: 4 // // End: //