Changeset ce02877 for doc/theses/mike_brooks_MMath/programs/hello-array.cfa
- Timestamp:
- Jul 29, 2024, 1:32:51 PM (2 months ago)
- Branches:
- master
- Children:
- f3d2a4f
- Parents:
- 38e20a80 (diff), 1661ad7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/mike_brooks_MMath/programs/hello-array.cfa
r38e20a80 rce02877 9 9 10 10 forall( [@N@] ) $\C{// array dimension}$ 11 array( bool, @N@ ) & f( array( float, @N@ ) & x, array( float, @N@ ) & y ) {11 array( bool, @N@ ) & f( array( float, @N@ ) & x, array( float, @N@ ) & y ) { 12 12 array( bool, @N@ ) & ret = *@alloc@(); $\C{// sizeof ret used by alloc}$ 13 13 for ( i; @N@ ) { … … 29 29 30 30 int 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}$ 34 34 x[i] = 3.14 / (i + 1); 35 35 y[i] = x[i] + 0.005 ; 36 36 } 37 array( bool, @ n@ ) & result = @f( x, y )@; $\C{// call}$37 array( bool, @dim@ ) & result = @f( x, y )@; $\C{// call}$ 38 38 sout | "result: " | nonl; $\C{// print result}$ 39 for ( i; n)39 for ( i; dim ) 40 40 sout | result[i] | nonl; 41 41 sout | nl;
Note: See TracChangeset
for help on using the changeset viewer.