<s> from sys import version_info <EOL> identity = lambda arg : arg <EOL> def _apply ( f , args = None , kwargs = None ) : <EOL> return f ( * ( args or [ ] ) , ** ( kwargs or { } ) ) <EOL> apply = apply if version_info [ <NUM_LIT:0> ] == <NUM_LIT:2> else _apply <EOL> def call ( f , * args , ** kwargs ) : <EOL> return f ( * args , ** kwargs ) <EOL> def flip ( f ) : <EOL> """<STR_LIT>""" <EOL> flipper = getattr ( f , "<STR_LIT>" , None ) <EOL> if flipper is not None : <EOL> return flipper <EOL> def _flipper ( a , b ) : <EOL> return f ( b , a ) <EOL> setattr ( _flipper , "<STR_LIT>" , f ) <EOL> return _flipper <EOL> def curry ( f , arg , * rest ) : <EOL> return curry ( f ( arg ) , * rest ) if rest else f ( arg ) <EOL> from . func import F <EOL> from . uniform import * <EOL> from itertools import starmap <EOL> def zipwith ( f ) : <EOL> '<STR_LIT>' <EOL> return F ( starmap , f ) << zip <EOL> def foldl ( f , init = None ) : <EOL> """<STR_LIT>""" <EOL> def fold ( it ) : <EOL> args = [ f , it ] <EOL> if init is not None : args . append ( init ) <EOL> return reduce ( * args ) <EOL> return fold <EOL> def foldr ( f , init = None ) : <EOL> """<STR_LIT>""" <EOL> def fold ( it ) : <EOL> args = [ flip ( f ) , reversed ( it ) ] <EOL> if init is not None : args . append ( init ) <EOL> return reduce ( * args ) <EOL> return fold <EOL> def unfold ( f ) : <EOL> """<STR_LIT>""" <EOL> def _unfolder ( start ) : <EOL> value , curr = None , start <EOL> while <NUM_LIT:1> : <EOL> step = f ( curr ) <EOL> if step is None : break <EOL> value , curr = step <EOL> yield value <EOL> return _unfolder </s>
