Differences From Artifact [157799e01f30b7fa]:
- File
sample/ast.pmy
- 2010-11-24 11:20:42 - part of checkin [153a14cec0] on branch trunk - if-then-else without {}s. some cosmetic changes (user: kinaba) [annotate]
To Artifact [a9061a338889d74c]:
- File
sample/ast.pmy
- 2010-11-24 11:45:25 - part of checkin [adacc96a55] on branch trunk - changed the syntax of pattern matching (user: kinaba) [annotate]
1 1 def reverse(lst, acc)
2 2 {
3 3 case(lst)
4 - when( {car:a, cdr: d} ) { reverse(d, {car:a, cdr:acc}) }
5 - when( {} ) { acc }
4 + when {car:a, cdr: d}: reverse(d, {car:a, cdr:acc})
5 + when {}: acc
6 6 };
7 7
8 8 @macro reverseArgs(e) {@value(
9 9 var ev = @macro(e);
10 10 case(ev)
11 - when( {is:"App", fun:f, args:a} )
12 - {
11 + when {is:"App", fun:f, args:a}:
12 + (
13 13 ev {args: reverse(a, {})}
14 - }
15 - when( _ )
16 - {
14 + )
15 + when _ :
16 + (
17 17 ev
18 - }
18 + )
19 19 )};
20 20
21 21 def main()
22 22 {
23 23 print( reverseArgs(1 + 2) );
24 24 print( reverseArgs(1 - 2) );
25 25 };
26 26
27 27 main()