def thread_last(val, *forms):
 def evalform_back(val, form):
  if callable(form):
   return form(val)
  if isinstance(form, tuple):
   (func, args) = (form[0], form[1:])
   args = (args + (val,))
   return func(*args)
 return reduce(evalform_back, forms, val)

def thread_last ( val , * forms ) : def evalform_back ( val , form ) : if callable ( form ) : return form ( val ) if isinstance ( form , tuple ) : ( func , args ) = ( form [ 0 ] , form [ 1 : ] ) args = ( args + ( val , ) ) return func ( * args ) return reduce ( evalform_back , forms , val )
thread value through a sequence of functions/forms .