Tail Recursive Merge in Java
public static Cons merjtr (Cons x, Cons y) { return nreverse(merjtrb(x, y, null)); } public static Cons merjtrb (Cons x, Cons y, Cons result) { if ( x == null ) if ( y == null ) return result; else return merjtrb(x, rest(y), cons(first(y), result)); else if ( ( y == null ) || ((Comparable) first(x)) .compareTo(first(y)) < 0 ) return merjtrb(rest(x), y, cons(first(x), result)); else return merjtrb(x, rest(y), cons(first(y), result));}