Assuming m and the items of a are boxed, then
a (f/"1 @ ,.) m
where f has the form (g each).
Steve
Fraser Jackson wrote:
What is the simplest way of expressing the very commonly needed
form of which the subject line is an example:
a3 f a2 f a1 f m
a list of items a =. a1, a2, a3, ... applied successively with a
function f and a right argument m of a different shape or even of a
different type. This occurs with any sequential updating process.
The intermediate results are often of interest themselves. recf does
what I want, but is there a neater way?
recf=: 1 : 0
:
s =. y
r =. ,:y
for_i.
i. # x
do. s =. (i{x) u s
r =. r,s
end.
r
)
2 4 6 8 10 + recf i. 2 2
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm