class IntSet19 { // Constructive Set class, // implemented using unordered ADT Lists private List list; public IntSet19() { list = List.empty(); } private IntSet19(List l) { list = l; } public IntSet19 delete(int n) { List list1 = delete(n,list); return new IntSet19(list1); } private static List delete(int n,List l) { if(l.isEmpty()) return List.empty(); else if(l.head()==n) return l.tail(); else return delete(n,l.tail()).cons(l.head()); } public IntSet19 add(int n) { List ptr; for(ptr=list; !ptr.isEmpty()&&ptr.head()!=n; ptr=ptr.tail()); if(ptr.isEmpty()) { List list1 = list.cons(n); return new IntSet19(list1); } else return this; } public boolean member(int n) { List ptr; for(ptr=list; !ptr.isEmpty()&&ptr.head()!=n; ptr=ptr.tail()); return (!ptr.isEmpty()); } public String toString() { String str="{"; if(!list.isEmpty()) { str+=list.head(); for(List ptr=list.tail(); !ptr.isEmpty(); ptr=ptr.tail()) str+=","+ptr.head(); } return str+"}"; } }