def thread(x, *fns):
    """Threads `x` left-to-right through the `fns`, returning the final result.
    thread x :: a -> a
    thread x, *fns :: a_0, *(a_i -> a_i+1) -> a_n"""
    for f in fns:
        x = f(x)
    return x