"""User-extensible Divacon helper library.

Anything callable defined here (and not starting with _) gets loaded into
the Divacon STDLIB by `pydc <prog.dc> <this-file>`, so .dc programs can
refer to it by name.

Convention: each helper takes one tuple argument (the comm'd tuple) and
returns the resulting scalar/tuple. Use destructuring on the first line."""

def runOnLeft(t):
    """((hereval, tailval), (otherhv, othertv)) -> (hereval, hereval + othertv)
       Drop-in adjustment used in scan-without-broadcast (left side of pair)."""
    L, R = t
    return (L[0],L[1] + R[1])

def runOnRight(t):
    """((hereval, tailval), (otherhv, othertv)) -> (hereval+othertv,tailval+othertv)
       Drop-in adjustment used in scan-without-broadcast (right side of pair)."""
    L, R = t
    return (L[0] + R[1],L[1] + R[1])

def id2x(A): return [(A[0],A[0])]
