Diff
Not logged in

Differences From Artifact [274d10aca22ce25f]:

To Artifact [977cd2f997805f91]:


1 -@macro twice(x) { x; x }; 1 +@macro twice = fun(x) { x; x }; 2 2 @macro max(x,y) { 3 3 var _x = x; # no hygenic macro btw.... 4 4 var _y = y; # no hygenic macro btw.... 5 5 if(_x<_y){_y}else{_x} 6 6 }; 7 7 def maxNormal(x,y) { 8 8 if(x<y){y}else{x} ................................................................................ 11 11 if(x<y){y}else{x} 12 12 }; 13 13 14 14 @macro LetItBe(x, y) { let it = x in y }; 15 15 16 16 @macro pow10(x) { 17 17 @value( 18 + def pow(y, n) { 19 + if( n == 1 ) { y } 20 + else { 21 + @macro( @value(y) * @value(pow(y,n-1)) ) 22 + } 23 + } 24 + in 25 + pow(@macro(x+1),10) 26 + ) 27 +}; 28 + 29 +@macro pow10Hard(x) { 30 + @value( 18 31 def pow(x, n) { 19 32 if( n == 1 ) { x } 20 33 else { 21 34 @macro( @value(x) * @value(pow(x,n-1)) ) 22 35 } 23 36 } 24 37 in 25 - pow(@macro(x),10) 38 + pow(@macro(x+1),10) 26 39 ) 27 40 }; 28 41 29 42 def printAndReturn(x) 30 43 { 31 44 print(x); 32 45 x 33 46 }; 34 - 35 - 36 - 37 - 38 47 39 48 def main() 40 49 { 41 50 twice( print("foo") ); 42 51 print("--------------"); 43 52 print(max(printAndReturn(100),printAndReturn(200))); 44 53 print("--------------"); 45 54 print(maxNormal(printAndReturn(100),printAndReturn(200))); 46 55 print("--------------"); 47 56 print(maxBad(printAndReturn(100),printAndReturn(200))); 48 57 print("--------------"); 49 58 print( LetItBe( 1+2+3, it*it ) ); 50 59 print("--------------"); 60 + print(pow10(1)); 51 61 print(pow10(2)); 62 + print("--------------"); 63 + print(pow10Hard(1)); 64 + print(pow10Hard(2)); 65 +}; 66 + 67 +main(); 68 + 69 +@macro foo(y) 70 +{ 71 + fun(y){y}(300) 72 +# let y = 300 in y 52 73 }; 53 74 54 -main() 75 +print("--------------"); 76 +print(foo(200));