func array_i( n )
    var a := array( n ), i;
    for( i:=0; i<len( a ); i++ )
        a[i] := i*i;
    end;
    return a;
end;

proc print( x )
    echo x, endl;
end;

proc arrays()
    var a := array_i( 4 );
    print( a );
    aadd( a, { 1, 2, 3 });
    print( a );
    adel( a, 2 );
    print( a );
end;

func rec( x )
    x=0 -> return 0;
    return 2*rec( x-1 )+1;
end;

proc structs()
    struct abc {a,b,c};
    struct def {d,e,f};
    abc x;
    def y;
    echo x,endl;
    x.b := y;
    y := nil;
    echo x,endl;
    x.b.e := true;
    echo x,endl;
end;

#define XY(x,y) x+y
#define AA 'a'
#define BB 'b'

proc defs()
#ifdef XY
    #ifdef AA
        echo XY(1,2),' ',XY(AA,BB),' ';
    #endif
#else
    qwerty
#endif
#undef XY
#define XY(x,y) x-y
    echo XY(2,1), endl;
end;

proc main()
    arrays();
    echo rec(1),' ',rec(3),' ',rec( rec(1)+rec(3)),endl;
    structs();
    defs();
end;

function atexit( s )
    echo s, endl;
    return len( s );
end;

