merge 2 lines together

def merge(l1, l2):
    """
    merge 2 lines together
    """
    x1, y1, x2, y2 = l1
    xx1, yy1, xx2, yy2 = l2

    comb = ((x1, y1, xx1, yy1),
            (x1, y1, xx2, yy2),
            (x2, y2, xx1, yy1),
            (x2, y2, xx2, yy2))

    d = [length(c) for c in comb]
    i = argmax(d)

    dist = d[i]
    mid = middle(comb[i])

    a = (angle(l1) + angle(l2)) * 0.5
    return fromAttr(mid, a, dist)