def piecewise(functions, conditions, fallback=lambda x : 0):
	"""
	Return a piecewise function such that if condition ``i`` in the given list
	of conditions is true, then the function at index ``i`` is executed. 

	If none of the conditions are satisfied, then the given fallback function
	is used (default is lambda x : 0).
	"""
	def _f(x):
		for i, condition in enumerate(conditions):
			if condition(x):
				return functions[i](x)
		return fallback(x)
	return _f