Changeset 4022


Ignore:
Timestamp:
Oct 31, 2008, 9:48:46 PM (12 years ago)
Author:
yura
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/java/refal/refal/plus/List2.rf

    r4020 r4022  
    8383$public $func? MapIn t.func e.list = e.list;
    8484MapIn t.func e.list = <Map (&MapInHelp t.func) e.list>;
     85
     86$func? ConcatMapInHelp t.func t.term = e.list;
     87ConcatMapInHelp t.func (e.expr) = <Apply t.func e.expr>;
     88
     89$public $func? ConcatMapIn t.func e.list = e.list;
     90ConcatMapIn t.func e.list = <Map (&ConcatMapInHelp t.func) e.list>;
    8591
    8692$func FilterHelp t.func t.term = e.term_or_empty;
     
    121127  } :: e.new_list (e.list1) (e.list2), # \{ e.list1 : v, e.list2 : v; } =
    122128  e.new_list;
     129
     130$public $func Transpose e.lists = e.lists;
     131Transpose e.lists = <TransposeWith &Paren e.lists>;
     132
     133$func? TransposeWithHelp e.lists = (e.heads) e.tails;
     134TransposeWithHelp e.lists =
     135  () () e.lists $iter {
     136    e.lists : (e.listsHead) e.listsTail =
     137      e.listsHead : t.head e.tail,
     138      (e.heads t.head) (e.tails (e.tail)) e.listsTail;
     139  } :: (e.heads) (e.tails) e.lists, e.lists : /* empty */ =
     140  (e.heads) e.tails;
     141 
     142$public $func? TransposeWith t.func e.lists = e.list;
     143TransposeWith t.func e.lists =
     144  (e.lists) $iter {
     145    <TransposeWithHelp e.lists> :: (e.heads) e.lists =
     146      e.out <Apply t.func e.heads> (e.lists);
     147    e.out ();   
     148  } :: e.out (e.lists), e.lists : /* empty */ =
     149  e.out;
     150
     151$public $func Product (e.list1) (e.list2) = e.list;
     152Product (e.list1) (e.list2) = <ProductWith &Paren (e.list1) (e.list2)>;
     153
     154$public $func? ProductWith t.func (e.list1) (e.list2) = e.list;
     155ProductWith t.func (e.list1) (e.list2) =
     156  <Box> :: s.box, {
     157    e.list1 : e t.term1 e,
     158      e.list2 : e t.term2 e,
     159      <Put s.box <Apply t.func t.term1 t.term2>>,
     160      $fail;
     161    <Get s.box>;
     162  };
     163
     164$public $func Products e.lists = e.lists;
     165Products {
     166  /* empty */ = /* empty */;
     167  (e.list) = <Map &Paren e.list>;
     168  (e.list) e.lists = <Product (e.list) (<Products e.lists>)>;
     169};
     170
     171$func? DirectProductWithHelp s.box t.func (e.args) e.lists = ;
     172DirectProductWithHelp s.box t.func (e.args) e.lists = e.lists : {
     173  /* empty */ = <Put s.box <Apply t.func e.args>>;
     174  (e.head) e.tail =
     175    {
     176      e.head : e t.term e,
     177        <DirectProductWithHelp s.box t.func (e.args t.term) e.tail>,
     178        $fail;;
     179    };
     180};
     181
     182$public $func? DirectProductWith t.func e.lists = e.list;
     183DirectProductWith t.func e.lists = {
     184  e.lists : /* empty */ = /* empty */;
     185  = <Box> :: s.box, <DirectProductWithHelp s.box t.func () e.lists>, <Get s.box>;
     186};
    123187
    124188$public $func? IsElem e.list t.item = ;
     
    274338  /* empty */   = /* empty */;
    275339  t.head e.tail = <QSort_Split (t.cmpTerms t.head) e.tail> :: (e.smaller) t (e.greater),
    276     <QSort e.smaller> t.head <QSort e.greater>;
     340    <QSortAndNubBy t.cmpTerms e.smaller> t.head <QSortAndNubBy t.cmpTerms e.greater>;
    277341};
    278342
Note: See TracChangeset for help on using the changeset viewer.