Overview
SHA1 Hash: | a5d10ace51e9ad7fde28ab52f0ffa523f4d42325 |
---|---|
Date: | 2010-11-10 00:35:18 |
User: | kinaba |
Comment: | FizzBuzz! |
Timelines: | family | ancestors | descendants | both | trunk |
Downloads: | Tarball | ZIP archive |
Other Links: | files | file ages | manifest |
Tags And Properties
- branch=trunk inherited from [f65680e1d2]
- sym-trunk inherited from [f65680e1d2]
Changes
Modified polemy/parse.d from [3e7ec41f1027e8ba] to [42c980cf31500e88].
174 scope(exit) lex.popFront; 174 scope(exit) lex.popFront; 175 return new IntLiteral(pos, BigInt(cast(string)lex.front. 175 return new IntLiteral(pos, BigInt(cast(string)lex.front. 176 } 176 } 177 if( tryEat("@") ) 177 if( tryEat("@") ) 178 { 178 { 179 auto lay = "@"~eatId("for layer ID"); 179 auto lay = "@"~eatId("for layer ID"); 180 eat("(", "for layered execution"); 180 eat("(", "for layered execution"); 181 auto e = E(0); | 181 auto e = Body(); 182 eat(")", "after "~lay~"(..."); 182 eat(")", "after "~lay~"(..."); 183 return new LayeredExpression(pos, lay, e); 183 return new LayeredExpression(pos, lay, e); 184 } 184 } 185 if( tryEat("(") ) 185 if( tryEat("(") ) 186 { 186 { 187 auto e = Body(); 187 auto e = Body(); 188 eat(")", "after parenthesized expression"); 188 eat(")", "after parenthesized expression");
Added sample/fizzbuzz.pmy version [d3f621f8aabb3e95]
> 1 # > 2 # Not at all a good example of the usage of layers, but anyway... > 3 # > 4 # after implementing layered parameters, this may be improved. > 5 # (though still not a good example...) > 6 # > 7 > 8 @ 3 print(x) { @v(print("Fizz")) }; > 9 @ 5 print(x) { @v(print("Buzz")) }; > 10 @15 print(x) { @v(print("FizzBuzz")) }; > 11 > 12 def fb(n, q3, q5, q15) { > 13 if( q15 < 1 ) { > 14 @15(print) > 15 } else { > 16 if( q5 < 1 ) { > 17 @5(print) > 18 } else { > 19 if( q3 < 1 ) { > 20 @3(print) > 21 } else { > 22 @v(print) > 23 } > 24 } > 25 }(n); > 26 let q3 = q3+1; > 27 let q5 = q5+1; > 28 let q15 = q15+1; > 29 > 30 fb( > 31 n+1, > 32 if(q3<3){q3}else{0}, > 33 if(q5<5){q5}else{0}, > 34 if(q15<15){q15}else{0} > 35 ) > 36 }; > 37 > 38 fb(0,0,0,0)