source: to-imperative/trunk/samples/perm3.rf @ 2303

Last change on this file since 2303 was 1684, checked in by orlov, 16 years ago
  • New samples.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 736 bytes
Line 
1$use StdIO;
2
3$func Gen-Perms expr = e.perms;
4
5Gen-Perms expr =
6  (/*e0*/) (expr) (/*e.perms*/) $iter {
7    expr : t1 e2 =
8      (e0 t1) (e2) (e.perms (t1 (<Gen-Perms e0 e2>)));
9  } :: (e0) (expr) (e.perms),
10  expr : /*empty*/ =
11  e.perms;
12
13
14$func Print-Perms (e.start) t.perm = ;
15
16Print-Perms {
17  (e.start) (t1 (v.perms)) =
18    {
19      v.perms : e t.p e,
20        <Print-Perms (e.start t1) t.p>,
21        $fail;;
22    };
23  (e.start) (t1 ()) = <PrintLN e.start t1>;
24};
25
26
27Main = {
28//  <Gen-Perms '1234'> : e t.p e,
29  <Gen-Perms '123456789'> :
30    e ('6' (e ('5' (e ('4' (e ('3' (e ('2' (e ('1' (e.p)) e)) e)) e)) e)) e)) e,
31    e.p : e t.q e,
32    <Print-Perms ('654321') t.q>,
33//    <WriteLN t.p>,
34//    <Print-Perms () t.p>,
35    $fail;;
36};
Note: See TracBrowser for help on using the repository browser.