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

Last change on this file since 2470 was 777, checked in by orlov, 18 years ago
  • Factorial through triple $iter.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 486 bytes
Line 
1$use StdIO;
2
3$func Fact e.N = t.F;
4
5Main =
6//  <PrintLN <Fact 'III'>>;
7  <Fact 'IIIIIIII'> : e;
8
9Fact e.N =
10  e.N () $iter {
11    e.N : e.N-1 t,
12      e.N-1 t.Fact $iter {
13        e.M : e.M-1 t,
14          t.Mul t.Fact $iter {
15            e.Mul : (e.Mul-1),
16              e.Mul-1 (t.Fact);
17          } :: e.Mul t.Fact,
18          e.Mul : /*empty*/ =
19          e.M-1 t.Fact;
20      } :: e.M t.Mul,
21      e.M : /*empty*/ =
22      e.N-1 t.Mul;
23  } :: e.N t.Fact,
24  e.N : /*empty*/ =
25  t.Fact;
26
Note: See TracBrowser for help on using the repository browser.