Changeset a65d92e for src/Tests/SynTree/Forall.c
- Timestamp:
- Jun 5, 2015, 9:34:43 AM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 59db689
- Parents:
- 44b5ca0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Tests/SynTree/Forall.c
r44b5ca0 ra65d92e 2 2 3 3 forall( type T ) 4 4 void swap( T left, T right ) { 5 5 T temp = left; 6 6 left = right; 7 7 right = temp; 8 8 } 9 9 10 10 context sumable( type T ) { … … 16 16 17 17 type T1 | { const T1 0; T1 ?+?(T1, T1); T1 ?++(T1); [T1] ?+=?(T1,T1); }, 18 19 18 T2(type P1, type P2 ), 19 T3 | sumable(T3); 20 20 21 21 type T2(type P1, type P2) | sumable(T2(P1,P2)) = struct { P1 i; P2 j; }; … … 28 28 29 29 forall( type T | sumable( T ) ) 30 30 T sum( int n, T a[] ) { 31 31 T total = 0; 32 32 int i; … … 34 34 total = total + a[i]; 35 35 return total; 36 36 } 37 37 38 38 forall( type T | { const T 0; T ?+?(T, T); T ?++(T); [T] ?+=?(T,T); } ) 39 39 T twice( T t ) { 40 40 return t + t; 41 41 } 42 42 43 43 int main() { … … 50 50 sum( 10, a ); 51 51 } 52 53 // Local Variables: // 54 // tab-width: 4 // 55 // End: //
Note: See TracChangeset
for help on using the changeset viewer.