def line_func(p1: list, p2: list):
    """Take two x,y points. Return a linear function through them both.

    :param p1: list of [x1, y1] ordered pair (point)
    :param p2: list of [x2, y2]
    :return: (linear) function in 1 variable, which passes through both points.
    """
    assert len(p1) == len(p2) == 2
    x1, y1, = p1
    x2, y2 = p2
    m = (y1 - y2) / (x1 - x2)  # let it raise error if x1 == x2
    return lambda x: m * (x - x1) + y1