Changeset 4020


Ignore:
Timestamp:
Oct 31, 2008, 7:26:18 PM (12 years ago)
Author:
yura
Message:
File:
1 edited

Legend:

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

    r4018 r4020  
    302302    e.right : /*empty*/ = e.merged e.left;
    303303  };
     304
     305$public $func SortAndNub e.list = e.list;
     306SortAndNub e.list = <SortBy &CompareTerms e.list>;
     307
     308$public $func SortAndNubBy t.cmpTerms e.list = e.list;
     309SortAndNubBy t.cmpTerms e.list =
     310  <Div <Length e.list> 2> : {
     311    0 = e.list;
     312    s.k = <MergeAndNub t.cmpTerms (<SortAndNubBy t.cmpTerms <Left 0 s.k e.list>>) (<SortAndNubBy t.cmpTerms <Middle s.k 0 e.list>>)>;
     313  };
     314
     315$func MergeAndNub t.cmpTerms (e.left) (e.right) = e.merged_list;
     316MergeAndNub t.cmpTerms (e.left) (e.right) =
     317  (e.left) (e.right) $iter {
     318    e.left : t.l e.left_rest, e.right : t.r e.right_rest = <Apply t.cmpTerms t.l t.r> : {
     319     '<' = e.merged t.l (e.left_rest) (e.right);
     320     '>' = e.merged t.r (e.left) (e.right_rest);
     321     '=' = e.merged (e.left) (e.right_rest);
     322    };
     323  } :: e.merged (e.left) (e.right),
     324  \{
     325    e.left  : /*empty*/ = e.merged e.right;
     326    e.right : /*empty*/ = e.merged e.left;
     327  };
Note: See TracChangeset for help on using the changeset viewer.