source: to-imperative/trunk/samples/select2.rf @ 2049

Last change on this file since 2049 was 760, checked in by orlov, 18 years ago
  • Code formatting.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 819 bytes
Line 
1//$use Dos StdIO; //TIMER;
2$use StdIO;
3
4$func  MkArg  eString = ePrefixes;
5$func  Select (eXs) eSets = eXs-or-sFail; * (eXs) or '*'
6$func? Sel    (eXs) eSets = (eXs);
7
8Main =
9  /*<PrintLN <Time>>,*/
10  <MkArg '1234567890ab'> :: e.Arg,
11  <PrintLN e.Arg>,
12  <Select () e.Arg> :: e.Res,
13  <PrintLN e.Res>,
14  /*<PrintLN <Time>>*/;
15
16MkArg e.String = * e.Prefixes
17  ( ) (e.String) $iter {
18    e.Prefix : e.Prefix-- s =
19      (e.Prefixes (e.Prefix)) (e.Prefix--) ;
20  } :: (e.Prefixes) (e.Prefix),
21  e.Prefix : /*empty*/
22   = e.Prefixes;
23
24Select (e.Xs) e.Sets = * e.Xs-or-sFail -- (eXs') or '*'
25  {
26    <Sel (e.Xs) e.Sets>;
27    '*';
28  };
29
30Sel (e.Xs) e.Sets = * (eXs) | $fail;
31  e.Sets : \{
32    /*empty*/ = (e.Xs);
33
34    (e.Set) e.Sets--,
35      e.Set : e sX e,
36      # \{ e.Xs : e s.X e; },
37      <Sel (e.Xs sX) e.Sets-->;
38  };
Note: See TracBrowser for help on using the repository browser.