Changeset 4031


Ignore:
Timestamp:
Nov 12, 2008, 5:56:28 PM (12 years ago)
Author:
yura
Message:
  • Improvements.
Location:
to-imperative/trunk/java
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/java/java/org/refal/plus/Util.java

    r3759 r4031  
    1818
    1919    public static BigInteger getBigInteger (Expr expr) throws ClassCastException {
    20         return (BigInteger) Util.getTerm(expr);
     20        return (BigInteger) getTerm(expr);
    2121    }
    2222
  • to-imperative/trunk/java/refal/refal/plus/List2.rf

    r4030 r4031  
    2424    = (s.func e.arg);
    2525  };
     26
    2627
    2728$public $func Ints s.start s.end = e.list;
     
    3738  };
    3839
    39 $public $func MapWithContext t.func e.list = e.list;
    40 MapWithContext t.func e.list =
    41   <Box> :: s.box,
    42   {
    43     e.list : e.left t.term e.right,
    44       <Put s.box <Apply t.func (e.left) t.term (e.right)>>,
    45       $fail;
    46     <Get s.box>;
    47   };
    4840
    4941$public $func? Head e.list = t.elem;
     
    7163};
    7264
     65
    7366$public $func? Map t.func e.list = e.list;
    7467Map t.func e.list =
     68  <SimplifyFunction t.func> :: s.func e.arg,
    7569  () e.list $iter {
    76     e.list : t.head e.tail = (e.new_list <Apply t.func t.head>) e.tail;
     70    e.list : t.head e.tail = (e.new_list <Apply.Apply s.func e.arg t.head>) e.tail;
    7771  } :: (e.new_list) e.list, e.list : /*empty*/ =
    7872  e.new_list;
    7973
    80 $func? MapInHelp t.func t.term = t.term;
    81 MapInHelp t.func (e.expr) = (<Apply t.func e.expr>);
     74$func? MapInHelp s.func e.arg t.term = t.term;
     75MapInHelp s.func e.arg (e.expr) = (<Apply.Apply s.func e.arg e.expr>);
    8276
    8377$public $func? MapIn t.func e.list = e.list;
    84 MapIn t.func e.list = <Map (&MapInHelp t.func) e.list>;
    85 
    86 $func? ConcatMapInHelp t.func t.term = e.list;
    87 ConcatMapInHelp t.func (e.expr) = <Apply t.func e.expr>;
     78MapIn t.func e.list = <Map (&MapInHelp <SimplifyFunction t.func>) e.list>;
     79
     80$func? ConcatMapInHelp s.func e.arg t.term = e.list;
     81ConcatMapInHelp s.func e.arg (e.expr) = <Apply.Apply s.func e.arg e.expr>;
    8882
    8983$public $func? ConcatMapIn t.func e.list = e.list;
    90 ConcatMapIn t.func e.list = <Map (&ConcatMapInHelp t.func) e.list>;
    91 
    92 $func FilterHelp t.func t.term = e.term_or_empty;
    93 FilterHelp t.func t.term = { <Apply t.func t.term> :: e = t.term; ; };
     84ConcatMapIn t.func e.list = <Map (&ConcatMapInHelp <SimplifyFunction t.func>) e.list>;
     85
     86$public $func MapWithContext t.func e.list = e.list;
     87MapWithContext t.func e.list =
     88  <SimplifyFunction t.func> :: s.func e.arg,
     89  <Box> :: s.box,
     90  {
     91    e.list : e.left t.term e.right,
     92      <Put s.box <Apply.Apply s.func e.arg (e.left) t.term (e.right)>>,
     93      $fail;
     94    <Get s.box>;
     95  };
     96
     97$func FilterHelp s.func e.arg t.term = e.term_or_empty;
     98FilterHelp s.func e.arg t.term = { <Apply.Apply s.func e.arg t.term> :: e = t.term; ; };
    9499
    95100$public $func Filter t.func e.list = e.list;
    96 Filter t.func e.list = <Map (&FilterHelp t.func) e.list>;
    97 
    98 $func? FilterInHelp t.func t.term = e.term_or_empty;
    99 FilterInHelp t.func t.term = t.term : (e.expr), { <Apply t.func e.expr> :: e = t.term; ; };
     101Filter t.func e.list = <Map (&FilterHelp <SimplifyFunction t.func>) e.list>;
     102
     103$func? FilterInHelp s.func e.arg t.term = e.term_or_empty;
     104FilterInHelp s.func e.arg t.term, t.term : (e.expr) = { <Apply.Apply s.func e.arg e.expr> :: e = t.term; ; };
    100105
    101106$public $func FilterIn t.func e.list = e.list;
    102 FilterIn t.func e.list = <Map (&FilterInHelp t.func) e.list>;
    103 
    104 $func FilterWithContextHelp t.func (e.left) t.term (e.right) = e.term_or_empty;
    105 FilterWithContextHelp t.func (e.left) t.term (e.right) = { <Apply t.func (e.left) t.term (e.right)> :: e = t.term; ; };
     107FilterIn t.func e.list = <Map (&FilterInHelp <SimplifyFunction t.func>) e.list>;
     108
     109$func FilterWithContextHelp s.func e.arg (e.left) t.term (e.right) = e.term_or_empty;
     110FilterWithContextHelp s.func e.arg (e.left) t.term (e.right) = { <Apply.Apply s.func e.arg (e.left) t.term (e.right)> :: e = t.term; ; };
    106111
    107112$public $func FilterWithContext t.func e.list = e.list;
    108 FilterWithContext t.func e.list = <MapWithContext (&FilterWithContextHelp t.func) e.list>;
     113FilterWithContext t.func e.list = <MapWithContext (&FilterWithContextHelp <SimplifyFunction t.func>) e.list>;
    109114
    110115$public $func Split t.func e.list = (e.true_list) (e.false_list);
    111116Split t.func e.list =
     117  <SimplifyFunction t.func> :: s.func e.arg,
    112118  () () e.list $iter {
    113119    e.list : t.head e.tail, {
    114       <Apply t.func t.head> :: e = (e.true_list t.head) (e.false_list) e.tail;
     120      <Apply.Apply s.func e.arg t.head> :: e = (e.true_list t.head) (e.false_list) e.tail;
    115121      = (e.true_list) (e.false_list t.head) e.tail;
    116122    };
     
    127133$public $func? ZipWith t.func (e.list1) (e.list2) = e.list;
    128134ZipWith t.func (e.list1) (e.list2) =
     135  <SimplifyFunction t.func> :: s.func e.arg,
    129136  /*empty*/ (e.list1) (e.list2) $iter {
    130137    e.list1 : t.first1 e.rest1,
    131138      e.list2 : t.first2 e.rest2 =
    132       e.new_list <Apply t.func t.first1 t.first2> (e.rest1) (e.rest2);
     139      e.new_list <Apply.Apply s.func e.arg t.first1 t.first2> (e.rest1) (e.rest2);
    133140  } :: e.new_list (e.list1) (e.list2), # \{ e.list1 : v, e.list2 : v; } =
    134141  e.new_list;
     
    148155$public $func? TransposeWith t.func e.lists = e.list;
    149156TransposeWith t.func e.lists =
     157  <SimplifyFunction t.func> :: s.func e.arg,
    150158  (e.lists) $iter {
    151159    <TransposeWithHelp e.lists> :: (e.heads) e.lists =
    152       e.out <Apply t.func e.heads> (e.lists);
     160      e.out <Apply.Apply s.func e.arg e.heads> (e.lists);
    153161    e.out ();   
    154162  } :: e.out (e.lists), e.lists : /* empty */ =
     
    160168$public $func? ProductWith t.func (e.list1) (e.list2) = e.list;
    161169ProductWith t.func (e.list1) (e.list2) =
     170  <SimplifyFunction t.func> :: s.func e.arg,
    162171  <Box> :: s.box, {
    163172    e.list1 : e t.term1 e,
    164173      e.list2 : e t.term2 e,
    165       <Put s.box <Apply t.func t.term1 t.term2>>,
     174      <Put s.box <Apply.Apply s.func e.arg t.term1 t.term2>>,
    166175      $fail;
    167176    <Get s.box>;
     
    171180DirectProduct e.lists = <DirectProductWith &Paren e.lists>;
    172181
    173 $func? DirectProductWithHelp t.func e.lists t.term = e.lists;
    174 DirectProductWithHelp t.func e.lists t.term = <DirectProductWith (t.func t.term) e.lists>;
     182$func? DirectProductWithSHelp (s.func e.arg) e.lists t.term = e.lists;
     183DirectProductWithSHelp (s.func e.arg) e.lists t.term = <DirectProductWithS (s.func e.arg t.term) e.lists>;
     184
     185$func? DirectProductWithS (s.func e.arg) e.lists = e.lists;
     186DirectProductWithS (s.func e.arg) e.lists = e.lists : {
     187  /* empty */ = <Apply.Apply s.func e.arg>;
     188  (e.list) e.tail = <Map (&DirectProductWithSHelp (s.func e.arg) e.tail) e.list>;
     189};
    175190
    176191$public $func? DirectProductWith t.func e.lists = e.lists;
    177 DirectProductWith t.func e.lists = e.lists : {
    178   /* empty */ = <Apply t.func>;
    179   (e.list) e.tail = <Map (&DirectProductWithHelp t.func e.tail) e.list>;
    180 };
     192DirectProductWith t.func e.lists = <DirectProductWithS (<SimplifyFunction t.func>) e.lists>;
    181193
    182194$public $func? IsElem e.list t.item = ;
     
    185197$public $func Foldl t.func (e.value) e.list = e.value;
    186198Foldl t.func (e.value) e.list =
     199  <SimplifyFunction t.func> :: s.func e.arg,
    187200  (e.value) e.list $iter {
    188     e.list : t.head e.tail = (<Apply t.func e.value t.head>) e.tail;
     201    e.list : t.head e.tail = (<Apply.Apply s.func e.arg e.value t.head>) e.tail;
    189202  } :: (e.value) e.list, e.list : /*empty*/ =
    190203  e.value;
     
    195208$public $func Foldr t.func (e.value) e.list = e.value;
    196209Foldr t.func (e.value) e.list =
     210  <SimplifyFunction t.func> :: s.func e.arg,
    197211  (e.value) e.list $iter {
    198     e.list : e.init t.last = (<Apply t.func t.last e.value>) e.init;
     212    e.list : e.init t.last = (<Apply.Apply s.func e.arg t.last e.value>) e.init;
    199213  } :: (e.value) e.list, e.list : /*empty*/ =
    200214  e.value;
     
    205219$public $func? All t.func e.list = ;
    206220All t.func e.list =
     221  <SimplifyFunction t.func> :: s.func e.arg,
    207222  e.list $iter {
    208     e.list : t.head e.tail = <Apply t.func t.head> :: e, e.tail;
     223    e.list : t.head e.tail = <Apply.Apply s.func e.arg t.head> :: e, e.tail;
    209224  } :: e.list, e.list : /*empty*/;
    210225
    211226$public $func? Any t.func e.list = ;
    212227Any t.func e.list = # \{
     228  <SimplifyFunction t.func> :: s.func e.arg,
    213229  e.list $iter {
    214     e.list : t.head e.tail = # \{ <Apply t.func t.head > :: e; }, e.tail;
     230    e.list : t.head e.tail = # \{ <Apply.Apply s.func e.arg t.head > :: e; }, e.tail;
    215231  } :: e.list, e.list : /*empty*/;
    216232};
Note: See TracChangeset for help on using the changeset viewer.