<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def scanl(f, n, ns):
 """Reduce ns by f starting with n yielding each intermediate value. tuple(scanl(f, n, ns))[-1] == reduce(f, ns, n) Parameters f : callable A binary function. n : any The starting value. ns : iterable of any The iterable to scan over. Yields ------ p : any The value of reduce(f, ns[:idx]) where idx is the current index. Examples -------- (0, 1, 3, 6, 10) """

    yield n
    for m in ns:
        n = f(n, m)
        yield n