Changeset 4031
- Timestamp:
- Nov 12, 2008, 5:56:28 PM (12 years ago)
- Location:
- to-imperative/trunk/java
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
to-imperative/trunk/java/java/org/refal/plus/Util.java
r3759 r4031 18 18 19 19 public static BigInteger getBigInteger (Expr expr) throws ClassCastException { 20 return (BigInteger) Util.getTerm(expr);20 return (BigInteger) getTerm(expr); 21 21 } 22 22 -
to-imperative/trunk/java/refal/refal/plus/List2.rf
r4030 r4031 24 24 = (s.func e.arg); 25 25 }; 26 26 27 27 28 $public $func Ints s.start s.end = e.list; … … 37 38 }; 38 39 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 };48 40 49 41 $public $func? Head e.list = t.elem; … … 71 63 }; 72 64 65 73 66 $public $func? Map t.func e.list = e.list; 74 67 Map t.func e.list = 68 <SimplifyFunction t.func> :: s.func e.arg, 75 69 () e.list $iter { 76 e.list : t.head e.tail = (e.new_list <Apply t.funct.head>) e.tail;70 e.list : t.head e.tail = (e.new_list <Apply.Apply s.func e.arg t.head>) e.tail; 77 71 } :: (e.new_list) e.list, e.list : /*empty*/ = 78 72 e.new_list; 79 73 80 $func? MapInHelp t.funct.term = t.term;81 MapInHelp t.func (e.expr) = (<Apply t.funce.expr>);74 $func? MapInHelp s.func e.arg t.term = t.term; 75 MapInHelp s.func e.arg (e.expr) = (<Apply.Apply s.func e.arg e.expr>); 82 76 83 77 $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.funct.term = e.list;87 ConcatMapInHelp t.func (e.expr) = <Apply t.funce.expr>;78 MapIn t.func e.list = <Map (&MapInHelp <SimplifyFunction t.func>) e.list>; 79 80 $func? ConcatMapInHelp s.func e.arg t.term = e.list; 81 ConcatMapInHelp s.func e.arg (e.expr) = <Apply.Apply s.func e.arg e.expr>; 88 82 89 83 $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; ; }; 84 ConcatMapIn t.func e.list = <Map (&ConcatMapInHelp <SimplifyFunction t.func>) e.list>; 85 86 $public $func MapWithContext t.func e.list = e.list; 87 MapWithContext 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; 98 FilterHelp s.func e.arg t.term = { <Apply.Apply s.func e.arg t.term> :: e = t.term; ; }; 94 99 95 100 $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.funct.term = e.term_or_empty;99 FilterInHelp t.func t.term = t.term : (e.expr), { <Apply t.funce.expr> :: e = t.term; ; };101 Filter 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; 104 FilterInHelp s.func e.arg t.term, t.term : (e.expr) = { <Apply.Apply s.func e.arg e.expr> :: e = t.term; ; }; 100 105 101 106 $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; ; };107 FilterIn 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; 110 FilterWithContextHelp 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; ; }; 106 111 107 112 $public $func FilterWithContext t.func e.list = e.list; 108 FilterWithContext t.func e.list = <MapWithContext (&FilterWithContextHelp t.func) e.list>;113 FilterWithContext t.func e.list = <MapWithContext (&FilterWithContextHelp <SimplifyFunction t.func>) e.list>; 109 114 110 115 $public $func Split t.func e.list = (e.true_list) (e.false_list); 111 116 Split t.func e.list = 117 <SimplifyFunction t.func> :: s.func e.arg, 112 118 () () e.list $iter { 113 119 e.list : t.head e.tail, { 114 <Apply t.funct.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; 115 121 = (e.true_list) (e.false_list t.head) e.tail; 116 122 }; … … 127 133 $public $func? ZipWith t.func (e.list1) (e.list2) = e.list; 128 134 ZipWith t.func (e.list1) (e.list2) = 135 <SimplifyFunction t.func> :: s.func e.arg, 129 136 /*empty*/ (e.list1) (e.list2) $iter { 130 137 e.list1 : t.first1 e.rest1, 131 138 e.list2 : t.first2 e.rest2 = 132 e.new_list <Apply t.funct.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); 133 140 } :: e.new_list (e.list1) (e.list2), # \{ e.list1 : v, e.list2 : v; } = 134 141 e.new_list; … … 148 155 $public $func? TransposeWith t.func e.lists = e.list; 149 156 TransposeWith t.func e.lists = 157 <SimplifyFunction t.func> :: s.func e.arg, 150 158 (e.lists) $iter { 151 159 <TransposeWithHelp e.lists> :: (e.heads) e.lists = 152 e.out <Apply t.funce.heads> (e.lists);160 e.out <Apply.Apply s.func e.arg e.heads> (e.lists); 153 161 e.out (); 154 162 } :: e.out (e.lists), e.lists : /* empty */ = … … 160 168 $public $func? ProductWith t.func (e.list1) (e.list2) = e.list; 161 169 ProductWith t.func (e.list1) (e.list2) = 170 <SimplifyFunction t.func> :: s.func e.arg, 162 171 <Box> :: s.box, { 163 172 e.list1 : e t.term1 e, 164 173 e.list2 : e t.term2 e, 165 <Put s.box <Apply t.funct.term1 t.term2>>,174 <Put s.box <Apply.Apply s.func e.arg t.term1 t.term2>>, 166 175 $fail; 167 176 <Get s.box>; … … 171 180 DirectProduct e.lists = <DirectProductWith &Paren e.lists>; 172 181 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; 183 DirectProductWithSHelp (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; 186 DirectProductWithS (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 }; 175 190 176 191 $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 }; 192 DirectProductWith t.func e.lists = <DirectProductWithS (<SimplifyFunction t.func>) e.lists>; 181 193 182 194 $public $func? IsElem e.list t.item = ; … … 185 197 $public $func Foldl t.func (e.value) e.list = e.value; 186 198 Foldl t.func (e.value) e.list = 199 <SimplifyFunction t.func> :: s.func e.arg, 187 200 (e.value) e.list $iter { 188 e.list : t.head e.tail = (<Apply t.funce.value t.head>) e.tail;201 e.list : t.head e.tail = (<Apply.Apply s.func e.arg e.value t.head>) e.tail; 189 202 } :: (e.value) e.list, e.list : /*empty*/ = 190 203 e.value; … … 195 208 $public $func Foldr t.func (e.value) e.list = e.value; 196 209 Foldr t.func (e.value) e.list = 210 <SimplifyFunction t.func> :: s.func e.arg, 197 211 (e.value) e.list $iter { 198 e.list : e.init t.last = (<Apply t.funct.last e.value>) e.init;212 e.list : e.init t.last = (<Apply.Apply s.func e.arg t.last e.value>) e.init; 199 213 } :: (e.value) e.list, e.list : /*empty*/ = 200 214 e.value; … … 205 219 $public $func? All t.func e.list = ; 206 220 All t.func e.list = 221 <SimplifyFunction t.func> :: s.func e.arg, 207 222 e.list $iter { 208 e.list : t.head e.tail = <Apply t.funct.head> :: e, e.tail;223 e.list : t.head e.tail = <Apply.Apply s.func e.arg t.head> :: e, e.tail; 209 224 } :: e.list, e.list : /*empty*/; 210 225 211 226 $public $func? Any t.func e.list = ; 212 227 Any t.func e.list = # \{ 228 <SimplifyFunction t.func> :: s.func e.arg, 213 229 e.list $iter { 214 e.list : t.head e.tail = # \{ <Apply t.funct.head > :: e; }, e.tail;230 e.list : t.head e.tail = # \{ <Apply.Apply s.func e.arg t.head > :: e; }, e.tail; 215 231 } :: e.list, e.list : /*empty*/; 216 232 };
Note: See TracChangeset
for help on using the changeset viewer.