home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / CALCPLUS.ZIP / EXAMPLE < prev    next >
Encoding:
Text File  |  1996-04-02  |  1.0 KB  |  69 lines

  1. func array_i( n )
  2.     var a := array( n ), i;
  3.     for( i:=0; i<len( a ); i++ )
  4.         a[i] := i*i;
  5.     end;
  6.     return a;
  7. end;
  8.  
  9. proc print( x )
  10.     echo x, endl;
  11. end;
  12.  
  13. proc arrays()
  14.     var a := array_i( 4 );
  15.     print( a );
  16.     aadd( a, { 1, 2, 3 });
  17.     print( a );
  18.     adel( a, 2 );
  19.     print( a );
  20. end;
  21.  
  22. func rec( x )
  23.     x=0 -> return 0;
  24.     return 2*rec( x-1 )+1;
  25. end;
  26.  
  27. proc structs()
  28.     struct abc {a,b,c};
  29.     struct def {d,e,f};
  30.     abc x;
  31.     def y;
  32.     echo x,endl;
  33.     x.b := y;
  34.     y := nil;
  35.     echo x,endl;
  36.     x.b.e := true;
  37.     echo x,endl;
  38. end;
  39.  
  40. #define XY(x,y) x+y
  41. #define AA 'a'
  42. #define BB 'b'
  43.  
  44. proc defs()
  45. #ifdef XY
  46.     #ifdef AA
  47.         echo XY(1,2),' ',XY(AA,BB),' ';
  48.     #endif
  49. #else
  50.     qwerty
  51. #endif
  52. #undef XY
  53. #define XY(x,y) x-y
  54.     echo XY(2,1), endl;
  55. end;
  56.  
  57. proc main()
  58.     arrays();
  59.     echo rec(1),' ',rec(3),' ',rec( rec(1)+rec(3)),endl;
  60.     structs();
  61.     defs();
  62. end;
  63.  
  64. function atexit( s )
  65.     echo s, endl;
  66.     return len( s );
  67. end;
  68.  
  69.