source: translator/examples/min.c @ a32b204

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 a32b204 was c11e31c, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

add inline and attribute qualifiers, cfa.y comment formatting, fix error message in isIntegralType

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