Changeset 4000


Ignore:
Timestamp:
Oct 25, 2008, 9:04:25 PM (12 years ago)
Author:
yura
Message:
  • Frequencies, SwapR
File:
1 edited

Legend:

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

    r3998 r4000  
    33$module "refal.plus.List2";
    44
    5 $use Apply Access Arithm Compare;
     5$use Apply Access Arithm Compare Table;
    66
    77$func SimplifyFunction t.func e.arg = s.func e.arg;
     
    140140    e.list : t.head e.tail, {
    141141      <Any (t.eqTerms t.head) e.new_list> = (e.new_list) e.tail;
    142       = (e.new_list (t.head)) e.tail;
     142      = (e.new_list t.head) e.tail;
    143143    };
    144144  } :: (e.new_list) e.list, e.list : /*empty*/ =
    145145  e.new_list;
     146
     147$public $func Frequencies e.list = e.list;
     148Frequencies e.list =
     149  <Table> :: s.table,
     150  {
     151    e.list : e t.term e,
     152      { <Lookup s.table t.term>; 0; } : s.num,
     153      <Bind s.table (t.term) (<Add s.num 1>)>,
     154      $fail;
     155    <MapIn &Concat <Entries s.table>>;
     156  };
     157
     158$public $func SwapR e.list = e.list;
     159SwapR {
     160  e.init t.last = t.last e.init;
     161  e.list = e.list;
     162};
    146163
    147164//Replicate s.n e.expr =
     
    186203  (e.left) (e.right) $iter {
    187204    e.left : t.l e.left_rest, e.right : t.r e.right_rest = {
    188       <Apply t.cmpTerms t.l t.r> : '<' = e.merged t.l (e.left_rest) (e.right);
     205     <Apply t.cmpTerms t.l t.r> : '<' = e.merged t.l (e.left_rest) (e.right);
    189206      = e.merged t.r (e.left) (e.right_rest);
    190207    };
Note: See TracChangeset for help on using the changeset viewer.