Index: sample/fizzbuzz.pmy ================================================================== --- sample/fizzbuzz.pmy +++ sample/fizzbuzz.pmy @@ -1,38 +1,20 @@ # # Not at all a good example of the usage of layers, but anyway... # -# after implementing layered parameters, this may be improved. -# (though still not a good example...) -# -@ 3 print(x) { @v(print("Fizz")) }; -@ 5 print(x) { @v(print("Buzz")) }; -@15 print(x) { @v(print("FizzBuzz")) }; +@@3(x){x}; +@@5(x){x}; +@@15(x){x}; +def incr(x) { x+1 }; +@ 3 incr(x) {@value( if(@ 3(x)+1< 3){@ 3(x)+1}else{0} )}; +@ 5 incr(x) {@value( if(@ 5(x)+1< 5){@ 5(x)+1}else{0} )}; +@15 incr(x) {@value( if(@15(x)+1<15){@15(x)+1}else{0} )}; -def fb(n, q3, q5, q15) { - if( q15 < 1 ) { - @15(print) - } else { - if( q5 < 1 ) { - @5(print) - } else { - if( q3 < 1 ) { - @3(print) - } else { - @v(print) - } - } - }(n); - let q3 = q3+1; - let q5 = q5+1; - let q15 = q15+1; - - fb( - n+1, - if(q3<3){q3}else{0}, - if(q5<5){q5}else{0}, - if(q15<15){q15}else{0} - ) +def fb(n @value @3 @5 @15) { + print( + if( @15(n) ) { if( @5(n) ) { if( @3(n) ) { n } else { "Fizz" } } else { "Buzz" } } else { "FizzBuzz" } + ); + fb(incr(n)) }; -fb(0,0,0,0) +fb(0) Index: sample/type.pmy ================================================================== --- sample/type.pmy +++ sample/type.pmy @@ -1,11 +1,10 @@ @@type = fun(x){ if( _isint(x) ) { "int" } else { if( _isstr(x) ) { "str" } - else { if( _isfun(x) ) { x } else { if( _isundefined(x) ) { "undefined" } - else { "any" }}}} + else { "any" }}} }; def binop(a,b,c) { fun(x,y){@value( if( @type(x)=="undefined" || @type(y)=="undefined" ) { "undefined" } else {