from interface import Eval

class Seq(Eval):
    def __init__( self):
        self.data = None

    def car(self):
        return self.data[0]

    def cdr(self):
        pass

    def cons(self):
        pass

    # The following four functions needed for iterability
    def __iter__(self):
        pass

    def __len__(self):
        pass

    def __contains__(self, e):
        pass

    def __getitem__(self, e):
        pass

    def __eq__(self, rhs):
        if not isinstance(rhs, Seq):
            return False

        if len(self) != len(rhs):
            return False

        for i in range(len(self.data)):
            if not self.data[i] == rhs.data[i]:
                return False

        return True


class List(Seq):
    def __init__(self, l=None):
        super(List, self).__init__()

        if l is None:
            self.data = []
        else:
            self.data = l

    def cdr(self):
        try:
            return List(self.data[1:])
        except:
            return List([])

    def cons(self, e):
        ret = List(self.data[:]) # bugfix 1234977437
        ret.data.insert(0, e)
        return ret

    def eval(self, env, args=None):
        form = self.car().eval(env)

        return form.eval(env, self.cdr())

    def __iter__(self):
        return self.data.__iter__()

    def __len__(self):
        return len(self.data)

    def __contains__(self, e):
        return e in self.data

    def __getitem__(self, e):
        return self.data[e]

    def __repr__(self):
        if self.data == []:
            return "()"

        ret = "(%s" % self.data[0]
        for e in self.data[1:]:
            ret = ret + " %s" % e

        return ret + ")"

@@ -286,36 +286,59 @@
 (self):%0A        
-pass
+return self.data.__iter__()
 %0A%0A    def __len_
@@ -346,36 +346,53 @@
 (self):%0A        
-pass
+return len(self.data)
 %0A%0A    def __cont
@@ -408,36 +408,53 @@
 lf, e):%0A        
-pass
+return e in self.data
 %0A%0A    def __geti
@@ -469,36 +469,51 @@
 lf, e):%0A        
-pass
+return self.data%5Be%5D
 %0A%0A    def __eq__
@@ -1327,244 +1327,8 @@
 ))%0A%0A
-    def __iter__(self):%0A        return self.data.__iter__()%0A%0A    def __len__(self):%0A        return len(self.data)%0A%0A    def __contains__(self, e):%0A        return e in self.data%0A%0A    def __getitem__(self, e):%0A        return self.data%5Be%5D%0A%0A
     

Clean up