source: to-imperative/trunk/samples/perm2.rf @ 2470

Last change on this file since 2470 was 1641, checked in by orlov, 16 years ago
  • A bit faster version.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 579 bytes
Line 
1$use Arithm StdIO Vector;
2
3$func Perm s = ;
4
5$vector V;
6$const  Len   = 10;
7$const  Len-1 = 9;
8
9Main =
10  <Vector-Replace &V (1) (2) (3) (4) (5) (6) (7) (8) (9) (0)>,
11  <Perm 0>;
12
13Perm sN, {
14  sN : &Len-1 = ;
15//    <PrintLN <Vector-To-Exp &V>>;
16  <"+" sN 1> :: sN1,
17    <Perm sN1>,
18    <Vector-Ref &V sN> :: e.tmp1,
19    sN1 $iter {
20      <Vector-Ref &V sM> :: e.tmp2,
21        <Vector-Set &V sM e.tmp1>,
22        <Vector-Set &V sN e.tmp2>,
23        <Perm sN1>,
24        <Vector-Set &V sM e.tmp2>,
25        <Vector-Set &V sN e.tmp1>,
26        <"+" sM 1>;
27    } :: sM,
28    sM : &Len;
29};
30
Note: See TracBrowser for help on using the repository browser.