Differences From Artifact [6b6d7ff7af65edf2]:
- File
sample/fizzbuzz.pmy
- 2010-11-21 16:05:20 - part of checkin [da7559b744] on branch trunk - fizzbuzz sample changed (user: kinaba) [annotate]
To Artifact [8920e9fd1d398081]:
- File
sample/fizzbuzz.pmy
- 2010-11-24 12:14:00 - part of checkin [3ae09b8cbf] on branch trunk - changed if-then-else syntax (user: kinaba) [annotate]
2 2 # Not at all a good example of the usage of layers, but anyway...
3 3 #
4 4
5 5 @@3(x){x};
6 6 @@5(x){x};
7 7 @@15(x){x};
8 8 def incr(x) { x+1 };
9 -@ 3 incr(x) {@value( if(@ 3(x)+1< 3){@ 3(x)+1}else{0} )};
10 -@ 5 incr(x) {@value( if(@ 5(x)+1< 5){@ 5(x)+1}else{0} )};
11 -@15 incr(x) {@value( if(@15(x)+1<15){@15(x)+1}else{0} )};
9 +@ 3 incr(x) {@value( if(@ 3(x)+1< 3)then@ 3(x)+1 else 0 )};
10 +@ 5 incr(x) {@value( if(@ 5(x)+1< 5)then@ 5(x)+1 else 0 )};
11 +@15 incr(x) {@value( if(@15(x)+1<15)then@15(x)+1 else 0 )};
12 12
13 13 def fb(n @value @3 @5 @15) {
14 - print(
15 - if( @15(n) ) { if( @5(n) ) { if( @3(n) ) { n } else { "Fizz" } } else { "Buzz" } } else { "FizzBuzz" }
16 - );
14 + print( if @15(n): if @5(n): if @3(n): n else: "Fizz" else "Buzz" else "FizzBuzz" );
17 15 fb(incr(n))
18 16 };
19 17
20 18 fb(0)