David,
First, understand that undoing ,&]/ is no different from undoing ,/ . This
isn't surprising: the definitions of the two verbs do not differ (viz the
DoJ); only the implementations do.
However, the implementation of ,/ is buggy; that's the sole reason ,&]/ was
introduced: as a workaround. If ,/ weren't broken there'd be no reason to
use ,&]/ at all.
If you prefer, you can substitute ,"_/ instead. As with &] , the adverb
"_ doesn't change the specified results of the verb; it serves only to hide
the derived verb from the (currently buggy) optimizer. It intrudes like a pane
of glass: transparently.
Given that, we can constrain our discussion to ,/ . What is the proper
obverse of that verb?
First, we must observe that the verb has no true inverse, because it
irrevocably loses information. Our saving grace is that you specified (in your
original message) that the obverse has access to precisely the information the
nominal verb discards: the shape of the original array. (A)
Since the only effect of ,/ is on the shape of the argument, and since we
know the desired shape of the proper obverse's result, the monad
original_shape&reshape would suffice if the dyad reshape guaranteed
desired_shape -: $ desired_shape reshape noun_with_an_arbitrary_shape . The
well-known idiom $ , so guarantees, and thus original_shape&($ ,) is a
proper obverse of ,/ .
I notice that Henry Rich already suggested that solution, and it did not
satisfy you. So apparently your question is more subtle than that. Perhaps
you perceive $ , to be inelegant or excessively forceful? If so, what
about Devon's solution, which exploits only the minimum required information
from the original shape (the first two axes)?
-Dan
(A) If I misunderstood your first message, and your question is
"how can we define po such that:
A =: ,/ y
y -: po A
or (more concisely):
f =: ,/ :. po
(-: ]&.f) y
obtains", the answer is: we cannot. There is no possible
definition of po which is ignorant of the (first two items
of) the shape of the original array. Absent that information,
,/ cannot be undone.
Concrete example of the obstacle:
$ ,/ i. 2 3
6
$ ,/ i. 3 2
6
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm