Hi,

1) Yes you can. Whether you should is another question: There's nothing
wrong with explicit code, and aiming to forcibly make everything tacit is
the way to a lot of frustration if you're trying to get things done,
especially if 3 or more arguments are needed to be juggled.

In most of such cases, clarity is far more important than writing things
tacitly.

That said, I also see the fun of trying to tacify such expressions. I came
up with this wording (together with some cooked up definitions of your
verbs)

   F=: {{ (tmp U y) V x W y P tmp=. x Q y}}
   nexec=: 0
   Q =. {{'Q',&< x,&<y[nexec=: nexec+1 }}
   P =: {{'P',&< x,&<y }}
   W =: {{'W',&< x,&<y }}
   V =: {{'V',&< x,&<y }}
   U =: {{'U',&< x,&<y }}

   X=: 0&{::
   Y=: 1&{::

   T =: Q ( (U Y) V ] (W~ X)~ (P~ Y)) ;

   rf =: 'x' F 'y'
   echo nexec
1
   nexec =: 0
   rt =: 'x' T 'y'
   rf -: rt NB. same result
1
   echo nexec NB. Q is only executed once
1

T is a fork, which puts x and y together in boxes and passes that to the
middle verb in parentheses, which also gets x Q y as left argument.

If your x and y have the same type and the same number of items, you could
also drop the boxing and use normal indexing ({) instead of fetch ({::).

2) No the interpreter does not remember the previous execution of Q.

Best regards,
Jan-Pieter

Op do 10 aug. 2023 om 15:14 schreef Marcin Żołek <
marcin.zo...@students.mimuw.edu.pl>

> Let U, V, W, P, Q be dyads and
>
> F =: dyad define
>     (tmp U y) V x W y P tmp =. x Q y
> )
>
> Tacit form of F, for example, is
>
> F =: (Q U ]) V [ W ] P Q
>
> but in this definition Q is repeated.
>
> 1. Is it possible to convert definition of F to tacit form without
> repeating Q in definition?
> 2. Does the interpreter recognize repetition of Q and evaluate Q only
> once? How to make the interpreter not evalute Q twice?
>
> Thanks,
> Martin
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to