def basis_function_one(degree, knot_vector, span, knot):
    """ Computes the value of a basis function for a single parameter.

    Implementation of Algorithm 2.4 from The NURBS Book by Piegl & Tiller.

    :param degree: degree, :math:`p`
    :type degree: int
    :param knot_vector: knot vector
    :type knot_vector: list, tuple
    :param span: knot span, :math:`i`
    :type span: int
    :param knot: knot or parameter, :math:`u`
    :type knot: float
    :return: basis function, :math:`N_{i,p}`
    :rtype: float
    """
    if span == 0 and knot == knot_vector[0] or span == len(knot_vector
        ) - degree - 2 and knot == knot_vector[len(knot_vector) - 1]:
        return 1.0
    if knot < knot_vector[span] or knot >= knot_vector[span + degree + 1]:
        return 0.0
    N = [(0.0) for _ in range(degree + span + 1)]
    for j in range(0, degree + 1):
        if knot_vector[span + j] <= knot < knot_vector[span + j + 1]:
            N[j] = 1.0
    for k in range(1, degree + 1):
        saved = 0.0
        if N[0] != 0.0:
            saved = (knot - knot_vector[span]) * N[0] / (knot_vector[span +
                k] - knot_vector[span])
        for j in range(0, degree - k + 1):
            Uleft = knot_vector[span + j + 1]
            Uright = knot_vector[span + j + k + 1]
            if N[j + 1] == 0.0:
                N[j] = saved
                saved = 0.0
            else:
                temp = N[j + 1] / (Uright - Uleft)
                N[j] = saved + (Uright - knot) * temp
                saved = (knot - Uleft) * temp
    return N[0]
