Changeset c3a8ecd for src/examples/twice.c
- Timestamp:
- Aug 14, 2018, 4:10:54 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 7cd8827
- Parents:
- 26f4dbe
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/twice.c
r26f4dbe rc3a8ecd 7 7 // twice.c -- 8 8 // 9 // Author : Richard C. Bilson9 // Author : Peter A. Buhr 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 8 22:04:58 201613 // Update Count : 1612 // Last Modified On : Thu Oct 19 21:52:57 2017 13 // Update Count : 46 14 14 // 15 15 16 16 #include <fstream> 17 17 18 forall( otype T | { T ?+?( T, T ); T ?++( T * ); [T] ?+=?( T *, T );} )18 forall( otype T | { T ?+?( T, T ); } ) 19 19 T twice( const T t ) { 20 20 return t + t; 21 21 } 22 22 23 // char does not have addition 24 char ?+?( char op1, char op2 ) { return (int)op1 + op2; } // cast forces integer addition or recursion 25 26 // signed char does not have addition 27 signed char ?+?( signed char op1, signed char op2 ) { return (int)op1 + op2; } // cast forces integer addition or recursion 28 23 29 int main( void ) { 24 // char does not have addition 25 char ?+?( char op1, char op2 ) { return (int)op1 + op2; } // cast forces integer addition or recursion 26 char ++?( char *op ) { *op += 1; return *op; } 27 char ?++( char *op ) { char temp = *op; *op += 1; return temp; } 28 29 sout | twice( 'a' ) | ' ' | twice( 1 ) | twice( 3.2 ) | endl; 30 sout | twice( ' ' ) | ' ' | twice( (signed char)0 ) | twice( (int)1 ) | twice( 3.2 ) | endl; 30 31 } 31 32
Note: See TracChangeset
for help on using the changeset viewer.