def ndeepmap(n, func, seq):
 if (n == 1):
  return [func(item) for item in seq]
 elif (n > 1):
  return [ndeepmap((n - 1), func, item) for item in seq]
 else:
  return func(seq)

def ndeepmap ( n , func , seq ) : if ( n == 1 ) : return [ func ( item ) for item in seq ] elif ( n > 1 ) : return [ ndeepmap ( ( n - 1 ) , func , item ) for item in seq ] else : return func ( seq )
call a function on every element within a nested container .