public List<A> reverse(){
  if (isEmpty() || tail.isEmpty())   return this;
  List<A> rev=nil();
  for (List<A> l=this; l.nonEmpty(); l=l.tail)   rev=new List<A>(l.head,rev);
  return rev;
}

public List < A > reverse ( ) { if ( isEmpty ( ) || tail . isEmpty ( ) ) return this ; List < A > rev = nil ( ) ; for ( List < A > l = this ; l . nonEmpty ( ) ; l = l . tail ) rev = new List < A > ( l . head , rev ) ; return rev ; }
reverse list . if the list is empty or a singleton , then the same list is returned . otherwise a new list is formed .
