Hi @jthi,
Thanks for your original input. Unfortunately, I have not managed to turn your suggestion into a workable script.
So I'm attaching another description of my objective (not a function script but rather a 'workflow').
Hopefully, someone can point me in the right direction.
Thanks
Sebastien
names default to here(1);
clear log();
sourcefitting={"a","b","c","d","e","f"};
/*The sourcefitting list can be 1000s longs and split in batches to perform some curve fitting, parameter extraction and them summarization using a FOR loo into a master table.
The process is expected to fail on some of those batches.
The failed items are identifed/listed into the 'failedfitting" list.
At which point a recursive loop using 'processX' needs to be implemented to take care of the remaining items using a new round of batching and fitting (for some reason the 'failing' process works on smaller batches but predicting which one will failed is not possible hence the need for a recessive loop), until the 'failedfittingX' list' is either empty or is stagnating (processfitting=1) ie the process keeps on failing and running the process another round is not longer warranted.
*/
processX=expr(/* process XYZ*/ //each time the processX is run 2 list are generated "succesfittingX" and "failedfittingX" are generated
//A new list "successfittingX" is generated at the end of the recursive loop
successfitting0={"a","c","d"};
/*
successfitting1={"a","c","d","b"};
successfitting2={"a","c","d","b","e"};
successfitting3={"a","c","d","b","e","f"}*/;// or successfitting3={"a","c","d","b","e"};
successfitting=successfittingX;
//The successfittingX and the sourcefitting lists are compared and a resulting list "failedfittingX" is created:
failedfitting0={"b","e","f"};
/*
failedfitting1={"e","f"};
failedfitting2={"f"};
failedfitting3={}*/; // or failedfitting3={"f"};
failedfitting=failedfittingX;
failednb=Nitems(failedfitting);
if(failedfittingX==failedfittingX-1,progressfitting=1, progressfitting=0);
);
//The issue is about correctly defining the structure recursive loop which uses the previous list to determine wheter the process needs to keep on going or if it is completed
// the use of the function 'recurse' has been suggested
testrec=function({failednb},
if(failednb>0&processfitting=0 ,recurse( processX),show("Done"))
);
testrec(failednb);