# Easiest way to simultaneously keep track of two values in a list

I have a bunch of functions a,b,c,... that all take in a list of images and return a list consisting of a list of transformed images, and a number (let's call it the 'error'). What I now want is a function that takes in a list of images and a list of a,b,c,... and returns a list of the final transformed images (after nested application of the functions) and a sum of the errors at each step.

Fold[#2[#1],imgs,{a,b,c,d}] allows me to apply all the functions to the images, however the first function will return a list and I only want the second function to act on the first element of it (the images). This also doesn't keep track of the sum of the error.

Is there any way to accomplish both transforming the images and summing the errors in a way that doesn't waste computation?

• I find your question a bit difficult to wrap my head around, but maybe you could take a look at FoldPair and FoldPairList? I think that should be relatively close to what you're looking for. – Sjoerd Smit Oct 2 at 11:42