I would use a fork, and 'bind' the left argument to the result of f. There is a difficulty, because you can't compose adverbs with verbs. Perhaps something like this:
c=. (*@] {{x}y}} ,:) f c i.10 0 1 2 3 1 2 6 1 2 9 You can get rid of the explicit definition using boxes, if you really care to, but I would not. -E On Sun, 29 May 2022, Brian Schott wrote: > I have a problem similar to the one shown below. > Both the verbs g and h depend on calculating f first so this seems like an > inefficient way of doing it where f produces only nonnegative integers from > its argument. > Is there a better approach? > > g=:,:f > h=:*@f > f=: 3&| NB. not the real f, but f is more compute heavy > 3 : '(h y)}g y' i.10 NB. an example calculation > 0 1 2 3 1 2 6 1 2 9 > ]`h`g } i. 10 NB. another "tacit" calculation > 0 1 2 3 1 2 6 1 2 9 > > > > -- > (B=) <-----my sig > Brian Schott > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm