source: to-imperative/trunk/samples/select1.rf @ 428

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