Ignore:
Timestamp:
Oct 25, 2024, 4:09:56 PM (5 months ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
33474e6
Parents:
d031f7f
Message:

Thesis, array, proofread intro sections.

Location:
doc/theses/mike_brooks_MMath/programs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified doc/theses/mike_brooks_MMath/programs/hello-accordion.cfa

    rd031f7f r720eec9  
    3939
    4040forall( [C], [S] )
    41 void init( @School( C, S ) & classes@, int class, int student, int pref ) with( classes ) {
    42         classIds[class] = class; $\C{// handle dynamic offsets of fields within structure}$
    43         studentIds[student] = student;
    44         preferences[class][student] = pref;
     41void put( @School( C, S ) & s@, int class, int student, int pref ) {
     42        s.classIds[class] = class; $\C{// fields' offsets are dynamic }$
     43        s.studentIds[student] = student;
     44        s.preferences[class][student] = pref;
    4545}
    4646
     
    6262        sin | classes | students;
    6363        @School( classes, students ) school;@
    64         int class, student, preference;
    65         // read data into school calling init
    66         // for each student's class/preferences
    67         try {
    68                 for ( ) {
    69                         sin | class | student | preference;
    70                         init( school, class, student, preference );
    71                 }
    72         } catch( end_of_file * ) {}
     64        // elided: read data into school, calling put
     65        {       int class, student, preference;
     66                // for each student's class/preferences
     67                try {
     68                        for ( ) {
     69                                sin | class | student | preference;
     70                                put( school, class, student, preference );
     71                        }
     72                } catch( end_of_file * ) {}        }
    7373        for ( s; students ) {
    7474                sout | "student" | s | nonl;
  • TabularUnified doc/theses/mike_brooks_MMath/programs/hello-array.cfa

    rd031f7f r720eec9  
    4949*/
    5050
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64#ifdef SHOWERR1
     65
    5166void fred() {
     67
     68
     69
     70        array( float, @10@ ) x;
     71        array( float, @20@ ) y;
     72        f( x, x );              $\C[0.5in]{// ok}$
     73        f( y, y );              $\C{// ok}$
     74        f( x, y );              $\C{// error}\CRT$
     75
     76
     77
     78
     79}
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90forall( [M], [N] )
     91void bad( array(float, M) &x,
     92                array(float, N) &y ) {
     93        f( x, x );              $\C[0.5in]{// ok}$
     94        f( y, y );              $\C{// ok}$
     95
     96        f( x, y );              $\C{// error}\CRT$
     97}
     98
     99#endif
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110forall( [M], [N] )
     111void bad_fixed( array( float, M ) & x,
     112                array( float, N ) & y ) {
     113        f( x, x );              $\C[0.5in]{// ok}$
     114        f( y, y );              $\C{// ok}$
     115        if ( M == N )
     116                f( x, @(array( float, M ) &)@y ); $\C{// ok}$
     117}
     118
     119
     120
     121
     122
     123
     124void fred_ok_only() {
    52125        array( float, @10@ ) x;
    53126        array( float, @20@ ) y;
     
    57130}
    58131
    59 #ifdef SHOWERR1
    60 forall( [M], [N] )
    61 void bad( array(float, M) &x, array(float, N) &y ) {
    62         f( x, x );              $\C[1.5in]{// ok}$
    63         f( y, y );              $\C{// ok}$
    64         f( x, y );              $\C{// error}\CRT$
    65 }
    66 #endif
    67 
    68 
    69132
    70133forall( [M], [N] )
    71 void bad_fixed( array( float, M ) & x, array( float, N ) & y ) {
    72         if ( M == N )
    73                 f( x, @(array( float, M ) &)@y ); $\C{// cast y to matching type}$
     134void bad_ok_only( array(float, M) &x,
     135                array(float, N) &y ) {
     136        f( x, x );
     137        f( y, y );
     138
     139//      f( x, y );
    74140}
     141
    75142
    76143// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.