<s> import collections <EOL> from python_toolbox import nifty_collections <EOL> from python_toolbox import caching <EOL> from python_toolbox import sequence_tools <EOL> infinity = float ( '<STR_LIT>' ) <EOL> class MapSpace ( sequence_tools . CuteSequenceMixin , collections . Sequence ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , function , sequence ) : <EOL> self . function = function <EOL> self . sequence = sequence_tools . ensure_iterable_is_immutable_sequence ( <EOL> sequence , <EOL> default_type = nifty_collections . LazyTuple <EOL> ) <EOL> length = caching . CachedProperty ( <EOL> lambda self : sequence_tools . get_length ( self . sequence ) <EOL> ) <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( <EOL> type ( self ) . __name__ , <EOL> self . function , <EOL> self . sequence <EOL> ) <EOL> def __getitem__ ( self , i ) : <EOL> if isinstance ( i , slice ) : <EOL> return type ( self ) ( self . function , self . sequence [ i ] ) <EOL> assert isinstance ( i , int ) <EOL> return self . function ( self . sequence [ i ] ) <EOL> def __iter__ ( self ) : <EOL> for item in self . sequence : <EOL> yield self . function ( item ) <EOL> _reduced = property ( <EOL> lambda self : ( type ( self ) , self . function , self . sequence ) <EOL> ) <EOL> __eq__ = lambda self , other : ( isinstance ( other , MapSpace ) and <EOL> self . _reduced == other . _reduced ) <EOL> __hash__ = lambda self : hash ( self . _reduced ) <EOL> __bool__ = lambda self : bool ( self . sequence ) </s>
