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

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