Contents    Page-10    Prev    Next    Page+10    Index   

Tail-Recursive Intersection in Java


public static Cons
       intersecttr (Cons x, Cons y) {
  return intersecttrb(x, y, null); }

public static Cons intersecttrb
                (Cons x, Cons y, Cons result) {
  if ( x == null )
     return result;
   else return intersecttrb(rest(x), y,
                 ( member(first(x), y) != null )
                 ? cons(first(x), result)
                 : result); }