Ignore:
Timestamp:
Nov 3, 2024, 9:13:16 PM (3 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
7d95bce9
Parents:
63a7394
Message:

proofread new material in background and array chapters

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

Legend:

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

    r63a7394 rc3e41cda  
    3030forall( [C], [S] )
    3131int getPref( @School( C, S ) & school@, int is, int pref ) {
    32     for ( ic; C ) {
    33         int curPref = @school.preferences@[ic][is];   $\C{// offset calculation implicit}$
     32        for ( ic; C ) {
     33                int curPref = @school.preferences@[ic][is];   $\C{// offset calculation implicit}$
    3434                if ( curPref == pref ) return ic;
    3535        }
    36     assert( false );
     36        assert( false );
    3737}
    3838
     
    5959
    6060        {       string sv;
    61         int iv;
    62         // headers' row
    63         sin | "\nc\\s";
    64         for ( is ; ns ) {
    65             // column label
    66             sin | sv;
    67             school.student_ids[is] = sv;
    68         }
    69         // body rows
    70         for ( ic ; nc ) {
    71             // row label
    72             sin | sv;
    73             school.course_codes[ic] = sv;
    74             for ( is ; ns ) {
    75                 // matrix item
    76                 sin | iv;
    77                 school.preferences[ic][is] = iv;
    78             }
    79         }
    80     }
     61                int iv;
     62                // headers' row
     63                sin | "\nc\\s";
     64                for ( is ; ns ) {
     65                        // column label
     66                        sin | sv;
     67                        school.student_ids[is] = sv;
     68                }
     69                // body rows
     70                for ( ic ; nc ) {
     71                        // row label
     72                        sin | sv;
     73                        school.course_codes[ic] = sv;
     74                        for ( is ; ns ) {
     75                                // matrix item
     76                                sin | iv;
     77                                school.preferences[ic][is] = iv;
     78                        }
     79                }
     80        }
    8181
    8282
     
    9191                sout | school.student_ids[is] | ": " | nonl;
    9292                for ( pref; 1 ~= nc ) {
    93             int ic = getPref(school, is, pref);
    94             sout | school.course_codes[ ic ] | nonl;
     93                        int ic = getPref(school, is, pref);
     94                        sout | school.course_codes[ ic ] | nonl;
    9595                }
    9696                sout | nl;
  • doc/theses/mike_brooks_MMath/programs/hello-array.cfa

    r63a7394 rc3e41cda  
    114114        f( y, y );              $\C{// ok}$
    115115        if ( M == N )
    116                 f( x, @(array( float, M ) &)@y ); $\C{// ok}$
     116                f( x, @(array( float, M ) &)@y ); $\C{// ok}\CRT$
    117117}
    118118
  • doc/theses/mike_brooks_MMath/programs/sharing-demo.cfa

    r63a7394 rc3e41cda  
    108108        assert( s2 == "bbb" );
    109109        sout | xstr(S2bbb) | "\t& " | s1 | "\t& " | s1a | "\t& " | s2 | "\t\\\\";
    110      
    111     #define S2S1a s2  = s1a
     110
     111        #define S2S1a s2  = s1a
    112112        S2S1a;
    113113        assert( s1 == "aaa" );
     
    122122        assert( s2 == "ccc" );
    123123        sout | xstr(S2ccc) | "\t& " | s1 | "\t& " | s1a | "\t& " | s2 | "\t\\\\";
    124      
     124
    125125        #define S1xxx s1  = "xxx"
    126126        S1xxx;
     
    149149
    150150        #define D2_s2_s1 string s2     = s1(1,2)
    151         D2_s2_s1;     
     151        D2_s2_s1;
    152152        assert( s1 == "abcd" );
    153153        assert( s1_mid == "bc" );
     
    157157        sout | "\\par\\noindent";
    158158
    159     sout | "Again, @`shareEdits@ passes changes in both directions; copy does not.  Note the difference in index values, with the \\emph{b} position being 1 in the longer string and 0 in the shorter strings.  In the case of s1 aliasing with @s1_mid@, the very same character is being accessed by different postitions.";
     159        sout | "Again, @`shareEdits@ passes changes in both directions; copy does not.  Note the difference in index values, with the \\emph{b} position being 1 in the longer string and 0 in the shorter strings.  In the case of s1 aliasing with @s1_mid@, the very same character is being accessed by different postitions.";
    160160        sout | "\\par\\noindent";
    161161        sout | "\\begin{tabular}{llll}";
     
    176176        assert( s2 == "bc" );
    177177        sout | xstr(D2_s1mid_minus) | "\t& " | s1 | "\t& " | s1_mid | "\t& " | s2 | "\t\\\\";
    178      
    179     #define D2_s2_pipe s2    [0] = '|'
     178
     179        #define D2_s2_pipe s2    [0] = '|'
    180180        D2_s2_pipe;
    181181        assert( s1 == "a-cd" );
     
    186186        sout | "\\par\\noindent";
    187187
    188     sout | "Once again, assignment of a value is a modificiation that flows through the aliasing relationship, without affecting its structure.";
     188        sout | "Once again, assignment of a value is a modificiation that flows through the aliasing relationship, without affecting its structure.";
    189189        sout | "\\par\\noindent";
    190190        sout | "\\begin{tabular}{llll}";
     
    198198        assert( s2 == "|c" );
    199199        sout | xstr(D2_s1mid_ff) | "\t& " | s1 | "\t& " | s1_mid | "\t& " | s2 | "\t\\\\";
    200      
     200
    201201        #define D2_s2_gg s2     = "gg"
    202202        D2_s2_gg;
     
    208208        sout | "\\par\\noindent";
    209209
    210     sout | "In the \\emph{ff} step, which is a positive example of flow across an aliasing relationship, the result is straightforward to accept because the flow direction is from contained (small) to containing (large).  The following rules for edits through aliasing substrings will guide how to flow in the opposite direction.";
     210        sout | "In the \\emph{ff} step, which is a positive example of flow across an aliasing relationship, the result is straightforward to accept because the flow direction is from contained (small) to containing (large).  The following rules for edits through aliasing substrings will guide how to flow in the opposite direction.";
    211211        sout | "\\par";
    212212
    213213
    214     sout | "Growth and shrinkage are natural extensions.  An empty substring is a real thing, at a well-defined location, whose meaning is extrapolated from the examples so far.  The intended metaphor is to operating a GUI text editor.  Having an aliasing substring is like using the mouse to select a few words.  Assigning onto an aliasign substring is like typing from having a few words selected:  depending how much you type, the file being edited can get shorter or longer.";
     214        sout | "Growth and shrinkage are natural extensions.  An empty substring is a real thing, at a well-defined location, whose meaning is extrapolated from the examples so far.  The intended metaphor is to operating a GUI text editor.  Having an aliasing substring is like using the mouse to select a few words.  Assigning onto an aliasign substring is like typing from having a few words selected:  depending how much you type, the file being edited can get shorter or longer.";
    215215        sout | "\\par\\noindent";
    216216        sout | "\\begin{tabular}{lll}";
     
    219219
    220220        assert( s1 == "affd" );
    221 //      assert( s1_mid == "fc" );                                                    // ????????? bug?
     221//      assert( s1_mid == "fc" );                                                                                                        // ????????? bug?
    222222        sout | xstr(D2_s2_gg) | "\t& " | s1 | "\t& " | s1_mid | "\t\\\\";
    223223
     
    227227        assert( s1_mid == "hhhh" );
    228228        sout  | xstr(D2_s1mid_hhhh)  | "\t& " | s1 | "\t& " | s1_mid | "\t\\\\";
    229      
     229
    230230        #define D2_s1mid_i s1_mid = "i"
    231231        D2_s1mid_i;
     
    248248        sout | "\\par\\noindent";
    249249
    250     sout | "Multiple portions can be aliased.  When there are several aliasing substrings at once, the text editor analogy becomes an online multi-user editor.  I should be able to edit a paragraph in one place (changing the document's length), without my edits affecting which letters are within a mouse-selection that you had made previously, somewhere else.";
     250        sout | "Multiple portions can be aliased.  When there are several aliasing substrings at once, the text editor analogy becomes an online multi-user editor.  I should be able to edit a paragraph in one place (changing the document's length), without my edits affecting which letters are within a mouse-selection that you had made previously, somewhere else.";
    251251        sout | "\\par\\noindent";
    252252        sout | "\\begin{tabular}{lllll}";
     
    264264        assert( s1_end == "d" );
    265265        sout  | xstr(D2_s1end_s1)  | "\t& " | s1 | "\t& " | s1_bgn | "\t& " | s1_mid | "\t& " | s1_end | "\t\\\\";
    266      
     266
    267267        #define D1_s1bgn_zzz s1_bgn = "zzzz"
    268268        D1_s1bgn_zzz;
     
    275275        sout | "\\par\\noindent";
    276276
    277     sout | "When an edit happens on an aliasing substring that overlaps another, an effect is unavoidable.  Here, the passive party sees its selection shortened, to exclude the characters that were not part of the original selection.";
     277        sout | "When an edit happens on an aliasing substring that overlaps another, an effect is unavoidable.  Here, the passive party sees its selection shortened, to exclude the characters that were not part of the original selection.";
    278278        sout | "\\par\\noindent";
    279279        sout | "\\begin{tabular}{llllll}";
     
    286286        assert( s1_crs == "zj" );
    287287        assert( s1_mid == "jj" );
    288         assert( s1_end == "d" ); 
     288        assert( s1_end == "d" );
    289289        sout  | xstr(D2_s1crs_s1)  | "\t& " | s1 | "\t& " | s1_bgn | "\t& " | s1_crs | "\t& " | s1_mid | "\t& " | s1_end | "\t\\\\";
    290290
     
    301301        sout | "TODO: finish typesetting the demo";
    302302
    303     // "This shortening behaviour means that a modification has to occur entirely inside a substring, to show up in that substring.  Sharing changes through the intersection of partially overlapping aliases is still possible, so long as the receiver's boundary is not inside the edit."
     303        // "This shortening behaviour means that a modification has to occur entirely inside a substring, to show up in that substring.  Sharing changes through the intersection of partially overlapping aliases is still possible, so long as the receiver's boundary is not inside the edit."
    304304
    305305        string word = "Phi";
     
    309309        assert( consonants == "Ph" );
    310310        assert( miniscules == "hi" );
    311      
     311
    312312        consonants[1] = 's';
    313313        assert( word == "Psi" );
     
    321321        string greet_bgn = all(10,1)`shareEdits;
    322322        string greet_end = all(14,1)`shareEdits;
    323      
     323
    324324        assert( all == "They said hello again" );
    325325        assert( greet == "hello" );
    326326        assert( greet_bgn == "h" );
    327327        assert( greet_end == "o" );
    328      
     328
    329329
    330330        greet = "sup";
     
    333333        // assert( greet_bgn == "" );    ------ Should be so, but fails
    334334        // assert( greet_end == "" );
    335      
    336 
    337  
    338 
    339  
    340     /* As in the earlier step where \emph{aj} becomes \emph{ajjd}, such empty substrings maintain their places in the total string, and can be used for filling it.  Because @greet_bgn@ was orginally at the start of the edit, in the outcome, the empty @greet_bgn@ sits just before the written value.  Similarly @greed_end@ goes after.  Though not shown, an overwritten substring at neither side goes arbitrarily to the before side. */
    341  
    342 
    343  
    344 
    345         greet_bgn = "what"; 
    346      
    347      
     335
     336
     337
     338
     339
     340        /* As in the earlier step where \emph{aj} becomes \emph{ajjd}, such empty substrings maintain their places in the total string, and can be used for filling it.  Because @greet_bgn@ was orginally at the start of the edit, in the outcome, the empty @greet_bgn@ sits just before the written value.  Similarly @greed_end@ goes after.  Though not shown, an overwritten substring at neither side goes arbitrarily to the before side. */
     341
     342
     343
     344
     345        greet_bgn = "what";
     346
     347
    348348        assert( all == "They said whatsup again" );
    349      
     349
    350350        assert( greet == "sup" );
    351      
     351
    352352        assert( greet_bgn == "what" );
    353353        // assert( greet_end == "" );    ------ Should be so, but fails
    354      
    355 
    356         greet_end = "..."; 
    357      
    358      
     354
     355
     356        greet_end = "...";
     357
     358
    359359        assert( all == "They said whatsup... again" );
    360      
     360
    361361        assert( greet == "sup" );
    362      
     362
    363363        assert( greet_bgn == "what" );
    364      
     364
    365365        assert( greet_end == "..." );
    366      
    367 
    368  
    369 
    370  
    371     /* Though these empty substrings hold their places in the total string, an empty string only belongs to bigger strings when it occurs completely inside them.  There is no such state as including an empty substring at an edge.  For this reason, @word@ gains the characters added by assigning to @greet_bgn@ and @greet_end@, but the string @greet@ does not. */
    372  
     366
     367
     368
     369
     370
     371        /* Though these empty substrings hold their places in the total string, an empty string only belongs to bigger strings when it occurs completely inside them.  There is no such state as including an empty substring at an edge.  For this reason, @word@ gains the characters added by assigning to @greet_bgn@ and @greet_end@, but the string @greet@ does not. */
     372
    373373
    374374}
     
    377377int main(int argc, char ** argv) {
    378378
    379     demo1();
    380     demo2();
    381     printf("%% %s done running\n", argv[0]);
     379        demo1();
     380        demo2();
     381        printf("%% %s done running\n", argv[0]);
    382382}
Note: See TracChangeset for help on using the changeset viewer.