Hope this will be clear enough; I am trying to pass 2 parameters (x;y) to a function, for convergence:
“x” being an initial table, which the convergence function will gradually modify until no change, using…
“y”, a list, which current value allows defining current conditions within the convergence function.
The first “y” value sets the 1st convergence function applied to table “x”. The resulting converged table, together with the second “y” value, then feed the next convergence… etc, up until the last item in the “y” list. Basically, the parameter “y” allows the condition(s), within the function to converge, to change as “y” is iterated and feeding the next loop.
The following pseudo code is what I am looking for:
Step 1
f:{[x;y]
cond based on 1st item of y;
x: <delete from x where cond>, until x is stable;
}/[initial table]/[first in list]
Step 2 & following: using table output from previous convergence, together with next element in list:
f:{[x;y]
cond based on n’th item of y;
x: <delete from x where cond>, until x is stable
}/[output table from previous step]/[next in list]
… obviously with the bizarre “/[table]/[list]” interpreted as <converge table> over <list>. I think it is possible to achieve this through encapsulation and/or .z.s, but my attempts have failed. Any help would be appreciated.
/An example t:( a:100?10;b:100?1.) /What I am looking for, (case of 2=count list) {[x;it] c1: (-1_(>‘:) (it+1)>xa),0b; /Cond1: ID first of each group of 1b's (source of convergence in this ex, til stable) c2: 0.5>abs log ratios next xb; /Cond2: Some value cond: $[1=it; c1; c1&c2]; /Set condition according to current param in [1 2] t: delete from x where cond|prev cond /Delete a duo of entries, where cond }/[t] … with each of [1 2] using the previously converged [t] /with its equivalent sequence of processing: { it: 2; c1: (-1_(>’:) (it+1)>xa),0b; c2: 0.5>abs log ratios next xb; cond: $[1=it; c1; c1&c2]; t: delete from x where cond|prev cond }/ [{ it: 1; c1: (-1_(>':) (it+1)>xa),0b; c2: 0.5>abs log ratios next xb; cond: $[1=it; c1; c1&c2]; t: delete from x where cond|prev cond }/[t]]
/ our diadic function takes two arguments / x will be the table / y will be the elements in the list incrementally / converge form of over shows final result q)t{y _ x}/2 -3 4 x - 6 / using scan you can see the intermediate changes q)t{y _ x}\2 -3 4 +(,x)!,2 3 4 5 6 7 8 9 +(,x)!,2 3 4 5 6 +(,`x)!,6
I perfectly understand your example, but there is no convergence per se. It is a standard iterative <over> a list applied to t, as in {y _ x}/[t;2 -3 4]. I realize that the title of my post was not a work of art:-)
I posted an example of what I am looking for just prior to your last reply; it uses a very short list of n=2 that needs to be fed into the convergence function (convergence in the sens of successive modifications to <t>, based on the current atom in the list, up until no further changes in <t>). Please look into it. Thx
Funny, I dug into it this am and came up with {f/[x;1 2]}/[t], but didn’t think (still not super fluent in q) about using the projection in the lambda.