Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: Java  |  size: 0.61 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public class NonEmptyList implements LispList {
  2.        
  3.         private Object hd;
  4.         private LispList tl;
  5.        
  6.    public NonEmptyList(Object h, EmptyList l)
  7.    {
  8.                 hd = h;
  9.                 tl = l;
  10.    }
  11.    
  12.     public NonEmptyList(Object h, NonEmptyList l)
  13.    {
  14.                 hd = h;
  15.                 tl = l;
  16.    }
  17.  
  18.         public LispList cons(Object h) {
  19.                
  20.                 return new NonEmptyList(h, this);
  21.         }
  22.  
  23.         public boolean isEmpty() {
  24.                 return false;
  25.         }
  26.  
  27.         public Object head() {
  28.                
  29.                 throw new UnsupportedOperationException();
  30.         }
  31.  
  32.         public LispList tail() {
  33.                
  34.                 throw new UnsupportedOperationException();
  35.         }
  36.  
  37.         public String toString() {
  38.        
  39.                 return "";
  40.         }
  41. }