#include typedef void* ent; class NonEmptyList { friend class repetition; friend class repetition_iterator; NonEmptyList *next; ent e; NonEmptyList (ent a, NonEmptyList *p) { e = a; next = p;} }; class repetition { friend class repetition_iterator; NonEmptyList *last; public: repetition() { last = 0; } repetition(ent a) { last = new NonEmptyList(a,0); last->next = last; } ~repetition() {} int insert(ent a); int append(ent a); ent get(); int list_length(); ent car(); void cdr(); ent lastexp(); ent n_th(int a); int conc(ent a , ent b); int concatenate(repetition * ); }; class repetition_iterator { NonEmptyList *ce; //current element repetition *cs; //list public: repetition_iterator(repetition &s) {cs = &s; ce = cs->last; } ent operator()() { ent ret = ce ? (ce = ce->next)->e : 0; // Law violation; friend documents if (ce == cs->last) ce = 0; return ret; } };