from typing import Tuple
from typing import Callable


def interpolate(p1: Tuple[int, float], p2: Tuple[int, float]) -> Callable[[int], float]:
	""" Returns a function that linearly interpolates between these two points.

	Implements the equation given in https://mathworld.wolfram.com/Two-PointForm.html
	
	Args:
		p1: A point (x1, y1) with the smaller x value.
		p2: A point (x2, y2) with the larger x value.

	Raises:
		ValueError if x1 is greater than x2.
	"""

	x2, y2 = p2
	x1, y1 = p1
	if x1 >= x2:
		raise ValueError(f"x2 ({x2}) must be greater than x1 ({x1}).")
	slope = (y2 - y1) / (x2 - x1)
	return lambda x: slope*(x - x2) + y2