@@ -1,5 +1,5 @@ -@macro twice(x) { x; x }; +@macro twice = fun(x) { x; x }; @macro max(x,y) { var _x = x; # no hygenic macro btw.... var _y = y; # no hygenic macro btw.... if(_x<_y){_y}else{_x} @@ -14,16 +14,29 @@ @macro LetItBe(x, y) { let it = x in y }; @macro pow10(x) { @value( + def pow(y, n) { + if( n == 1 ) { y } + else { + @macro( @value(y) * @value(pow(y,n-1)) ) + } + } + in + pow(@macro(x+1),10) + ) +}; + +@macro pow10Hard(x) { + @value( def pow(x, n) { if( n == 1 ) { x } else { @macro( @value(x) * @value(pow(x,n-1)) ) } } in - pow(@macro(x),10) + pow(@macro(x+1),10) ) }; def printAndReturn(x) @@ -30,12 +43,8 @@ { print(x); x }; - - - - def main() { twice( print("foo") ); @@ -47,8 +56,21 @@ print(maxBad(printAndReturn(100),printAndReturn(200))); print("--------------"); print( LetItBe( 1+2+3, it*it ) ); print("--------------"); + print(pow10(1)); print(pow10(2)); + print("--------------"); + print(pow10Hard(1)); + print(pow10Hard(2)); +}; + +main(); + +@macro foo(y) +{ + fun(y){y}(300) +# let y = 300 in y }; -main() +print("--------------"); +print(foo(200));