Ignore:
Timestamp:
Jul 29, 2024, 9:49:07 AM (16 hours ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
b67d7a5b
Parents:
b8e047a
Message:

proofread array chapter and update example programs

File:
1 edited

Legend:

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

    rb8e047a rcaa3e2c  
    99
    1010forall( [@N@] )                                                         $\C{// array dimension}$
    11 array( bool, @N@) & f( array( float, @N@ ) & x, array( float, @N@ ) & y ) {
     11array( bool, @N@ ) & f( array( float, @N@ ) & x, array( float, @N@ ) & y ) {
    1212        array( bool, @N@ ) & ret = *@alloc@();  $\C{// sizeof ret  used by alloc}$
    1313        for ( i; @N@ ) {
     
    2929
    3030int main( int argc, char * argv[] ) {
    31         const int @n@ = ato( argv[1] );                 $\C{// deduce conversion type}$
    32         array( float, @n@ ) x, y;                               $\C{// VLAs}$
    33         for ( i; n ) {                                                  $\C{// initialize arrays}$
     31        const int @dim@ = ato( argv[1] );               $\C{// deduce conversion type}$
     32        array( float, @dim@ ) x, y;                             $\C{// VLAs}$
     33        for ( i; dim ) {                                                $\C{// initialize arrays}$
    3434                x[i] = 3.14 / (i + 1);
    3535                y[i] = x[i] + 0.005 ;
    3636        }
    37         array( bool, @n@ ) & result = @f( x, y )@; $\C{// call}$
     37        array( bool, @dim@ ) & result = @f( x, y )@; $\C{// call}$
    3838        sout | "result: " | nonl;                               $\C{// print result}$
    39         for ( i; n )
     39        for ( i; dim )
    4040                sout | result[i] | nonl;
    4141        sout | nl;
Note: See TracChangeset for help on using the changeset viewer.