On Mon, Sep 11, 2023 at 2:48 AM 'Skip Cave' via Programming
<programm...@jsoftware.com> wrote:
> Raul used a 'chain of dyadic verbs' (x F x F x F y) to solve the problem. I
> haven't ever tried this, where right-to-left execution is used to feed the
> result of one dyadic verb into the next one on the left. It was a bit
> confusing until I realized that the rightmost verb 'eats' its left
> argument, so that the verb result is passed to the next verb on the left,
> instead of the previous verb's left argument. This problem provides a good
> example of the use of this feature.  I wonder if this linear 'chain of
> verbs' could be replaced with the hatco operator (^:)?

You could use (^:) if you could derive the left argument from the
right argument.

For example, replacing (x) with (#digits y).

If that had not been possible, you could have used (/) instead of (^:)
but that forces you to box y and the individual x values so that they
could exist in a list together (and then you have to unbox them when
using them). Alternatively you could have used (]F.:) which behaves
similarly but allows an initial value (which would be N1 here) as a
left argument rather than being the rightmost element of the array.
(But this is a hypothetical general case, because deriving the x
argument from the y argument is straightforward here.)

FYI,

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to