<s> class ImmutableList ( object ) : <EOL> def __init__ ( self , * args ) : <EOL> if len ( args ) == <NUM_LIT:0> : <EOL> self . _empty = True <EOL> self . _head = None <EOL> self . _tail = None <EOL> elif len ( args ) == <NUM_LIT:1> and isinstance ( args [ <NUM_LIT:0> ] , ( list , tuple ) ) : <EOL> if len ( args [ <NUM_LIT:0> ] ) == <NUM_LIT:0> : <EOL> self . _empty = True <EOL> self . _head = None <EOL> self . _tail = None <EOL> else : <EOL> self . _head = args [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> if len ( args [ <NUM_LIT:0> ] ) > <NUM_LIT:1> : <EOL> self . _tail = ImmutableList ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> : ] ) <EOL> else : self . _tail = ImmutableList ( ) <EOL> self . _empty = False <EOL> elif len ( args ) == <NUM_LIT:2> and isinstance ( args [ <NUM_LIT:1> ] , ImmutableList ) : <EOL> self . _head = args [ <NUM_LIT:0> ] <EOL> self . _tail = args [ <NUM_LIT:1> ] <EOL> self . _empty = False <EOL> def conj ( self , itm ) : <EOL> return ImmutableList ( itm , self ) <EOL> def first ( self ) : <EOL> return self . _head <EOL> def rest ( self ) : <EOL> if self . _empty : <EOL> return self <EOL> return self . _tail <EOL> def second ( self ) : <EOL> if self . _empty : <EOL> return None <EOL> return self . _tail . _head <EOL> def empty ( self ) : <EOL> return self . _empty <EOL> def __contains__ ( self , itm ) : <EOL> if self . _empty : <EOL> return False <EOL> if self . _head == itm : <EOL> return True <EOL> return itm in self . _tail <EOL> def __iter__ ( self ) : <EOL> node = self <EOL> while not node . _empty : <EOL> yield node . _head <EOL> node = node . _tail <EOL> def __eq__ ( self , other ) : <EOL> if other is None : <EOL> return False <EOL> if not hasattr ( other , '<STR_LIT>' ) : <EOL> return False <EOL> node = self <EOL> for itm in other : <EOL> if node . _empty : <EOL> return False <EOL> if node . _head != itm : <EOL> return False <EOL> node = node . _tail <EOL> return True <EOL> def __ne__ ( self , other ) : <EOL> return not self . __eq__ ( other ) <EOL> def __len__ ( self ) : <EOL> if self . _empty : <EOL> return <NUM_LIT:0> <EOL> else : <EOL> return <NUM_LIT:1> + len ( self . _tail ) <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT:[>' + '<STR_LIT:U+002CU+0020>' . join ( [ str ( x ) for x in self ] ) + '<STR_LIT:]>' <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' + str ( self ) + '<STR_LIT:)>' </s>
