source: translator/examples/min.c @ 42e2ad7

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since 42e2ad7 was bdd516a, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

fixed sizeof type variable, find lowest cost alternative for sizeof expression, removed unused classes, added compiler flag, remove temporary file for -CFA, formatting

  • Property mode set to 100644
File size: 543 bytes
RevLine 
[a0d9f94]1extern "C" {
2    int printf( const char *, ... );
3}
4
[42dcae7]5forall( type T | { int ?<?( T, T ); } )
[3848e0e]6T min( const T t1, const T t2 ) {
[a0d9f94]7    return t1 < t2 ? t1 : t2;
8}
9
10int main() {
[3848e0e]11    char c;
[bdd516a]12    c = min( 'z', 'a' );
[3848e0e]13    printf( "minimum %d\n", c );
[42dcae7]14    int i;
15    i = min( 4, 3 );
16    printf( "minimum %d\n", min( 4, 3 ) );
[a0d9f94]17    float f;
[42dcae7]18    f = min( 4.0, 3.1 );
19    printf( "minimum %g\n", f );
20    double d;
21    d = min( 4.0, 3.2 );
22    printf( "minimum %g\n", d );
[a0d9f94]23}
[42dcae7]24
25// Local Variables: //
26// compile-command: "../../bin/cfa min.c" //
27// End: //
Note: See TracBrowser for help on using the repository browser.