Ignore:
Timestamp:
Jan 29, 2016, 4:36:39 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
ae8b942
Parents:
f3fc8cbe
Message:

building runtime library (first attempt)

File:
1 moved

Legend:

Unmodified
Added
Removed
  • src/examples/minmax.c

    rf3fc8cbe rd3b7937  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  4 11:40:51 2016
    13 // Update Count     : 26
     12// Last Modified On : Thu Jan 28 22:15:14 2016
     13// Update Count     : 42
    1414//
    1515
    16 #include "fstream.h"
    17 
    18 forall( type T | { int ?<?( T, T ); } )
    19 T min( const T t1, const T t2 ) {
    20         return t1 < t2 ? t1 : t2;
    21 } // min
     16#include <fstream>
     17#include <algorithm>
    2218
    2319int main( void ) {
    2420        ofstream *sout = ofstream_stdout();
    25         // char does not have less than.
     21        // char does not have less or greater than.
    2622        int ?<?( char op1, char op2 ) { return (int)op1 < (int)op2; }
     23        int ?>?( char op1, char op2 ) { return (int)op1 > (int)op2; }
    2724
    2825        sout | "char\t\t\t"                                     | 'z' | ' ' | 'a' | "\tmin " | min( 'z', 'a' ) | endl;
     
    3633        sout | "double\t\t\t"                           | 4.0 | ' ' | 3.1 | "\tmin " | min( 4.0, 3.1 ) | endl;
    3734        sout | "long double\t\t"                        | 4.0l | ' ' | 3.1l | "\tmin " | min( 4.0l, 3.1l ) | endl;
     35        sout | endl;
     36        sout | "char\t\t\t"                                     | 'z' | ' ' | 'a' | "\tmax " | max( 'z', 'a' ) | endl;
     37        sout | "signed int\t\t"                         | 4 | ' ' | 3 | "\tmax " | max( 4, 3 ) | endl;
     38        sout | "unsigned int\t\t"                       | 4u | ' ' | 3u | "\tmax " | max( 4u, 3u ) | endl;
     39        sout | "signed long int\t\t"            | 4l | ' ' | 3l | "\tmax " | max( 4l, 3l ) | endl;
     40        sout | "unsigned long int\t"            | 4ul | ' ' | 3ul | "\tmax " | max( 4ul, 3ul ) | endl;
     41        sout | "signed long long int\t"         | 4ll | ' ' | 3ll | "\tmax " | max( 4ll, 3ll ) | endl;
     42        sout | "unsigned long long int\t"       | 4ull | ' ' | 3ull | "\tmax " | max( 4ull, 3ull ) | endl;
     43        sout | "float\t\t\t"                            | 4.0f | ' ' | 3.1f | "\tmax " | max( 4.0f, 3.1f ) | endl;
     44        sout | "double\t\t\t"                           | 4.0 | ' ' | 3.1 | "\tmax " | max( 4.0, 3.1 ) | endl;
     45        sout | "long double\t\t"                        | 4.0l | ' ' | 3.1l | "\tmax " | max( 4.0l, 3.1l ) | endl;
    3846} // main
    3947
    4048// Local Variables: //
    4149// tab-width: 4 //
    42 // compile-command: "cfa min.c fstream.o iostream.o iterator.o" //
     50// compile-command: "cfa minmax.c" //
    4351// End: //
Note: See TracChangeset for help on using the changeset viewer.