<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def closest_point(a, b, p):
 """Finds closest point in a line segment Args: a ([float, float]):
 x and y coordinates. Line start b ([float, float]):
 x and y coordinates. Line end p ([float, float]):
 x and y coordinates. Point to find in the segment Returns: (float, float):
 x and y coordinates of the closest point """

    ap = [p[0]-a[0], p[1]-a[1]]
    ab = [b[0]-a[0], b[1]-a[1]]
    mag = float(ab[0]**2 + ab[1]**2)
    proj = dot(ap, ab)
    if mag ==0 :
        dist = 0
    else:
        dist = proj / mag
    if dist < 0:
        return [a[0], a[1]]
    elif dist > 1:
        return [b[0], b[1]]
    else:
        return [a[0] + ab[0] * dist, a[1] + ab[1] * dist]