Chain function calls based on array



I am trying to figure out a way to, given:

addtest(a, b) = a+ b
test = [1, 2, 3, 4]
y = 10

… translate:

for a in test
    y += addtest(a, y)


y = addtest(test[1], y)
y = addtest(test[2], y)

The reason why is I am using the Lazy package ( to chain function calls together, and the real situation I am using it in requires some way to apply a function N times with the values in an array of length N as an argument to that function each time it is called. In other words, something like this (which doesn’t work):

@as x 10 begin
        for f = test
            addtest(f, x)


I’m not sure, but is foldl((y, x) -> addtest(x, y) + y, test; init=10) what you need?