def clampf(f, x_min, x_max):
	"""
	Return a new function that is the given function clamped on its domain
	between the given x_min and x_max values.
	"""
	return lambda t : f(x_max if t > x_max else x_min if t < x_min else t)