source: translator/examples/min.c @ 9df2dd5

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 9df2dd5 was 3848e0e, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

underscore changes, ptrdiff_t changes, formating, _Bool prelude

  • Property mode set to 100644
File size: 543 bytes
Line 
1extern "C" {
2    int printf( const char *, ... );
3}
4
5forall( type T | { int ?<?( T, T ); } )
6T min( const T t1, const T t2 ) {
7    return t1 < t2 ? t1 : t2;
8}
9
10int main() {
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 ) );
17    float f;
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 );
23}
24
25// Local Variables: //
26// compile-command: "../../bin/cfa min.c" //
27// End: //
Note: See TracBrowser for help on using the repository browser.