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

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 42dcae7 was 42dcae7, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

re-inserted remove and reorder hoisted aggregate, fixed example programs

  • Property mode set to 100644
File size: 537 bytes
RevLine 
[a0d9f94]1extern "C" {
2    int printf( const char *, ... );
3}
4
[42dcae7]5forall( type T | { int ?<?( T, T ); } )
[a0d9f94]6T min( T t1, T t2 ) {
7    return t1 < t2 ? t1 : t2;
8}
9
10int main() {
[42dcae7]11//    char c;
12//    c = min( 'a', 'z' );
13//    printf( "minimum %d\n", c );
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.