Using sort instead of amend makes it easy to turn this into a tacit
verb:

   x=: 5 6 ?@$ 100
   x -: ($x) ([ $ (/:&; </.@:i.)~) </.x
1

If we combine that with a spoiler for Roger's shape exercise, we get a
nice bivalent form.

deoblique =: ($:~ [: ((1+i.,i:)>./) #@>) : ([ $ (/:&; </.@:i.)~)

   x -: ($x) deoblique </.x
1
   x -: deoblique </.x
1

The catch for the monad form is that it can't distinguish between, for
instance, a shape of 5 6 and a shape of 6 5. This information is lost by
(</.), so it can't be recovered. deoblique chooses the ascending shape
for nonsquare arguments.

Marshall

On Wed, Feb 17, 2016 at 08:59:44AM -0800, Roger Hui wrote:
> Assuming you know the shape of the original argument:
> 
>    x=: 5 6 ?@$ 100
>    x -: (;</.x) (;</.{i.&.>$x)} 5 6$0
> 1
> 
> Deriving the shape of the original x from </.x is left as an exercise for
> the reader ...
> 
> 
> 
> 
> On Wed, Feb 17, 2016 at 8:45 AM, Pascal Jasmin <[email protected]>
> wrote:
> 
> > More specific to what I want, based on looking at diagonal relationships
> > within data, I wish to update a value in the original matrix, but I think
> > the original question is easier more flexible.  I can't think of a better
> > way than to generate indexes,
> >
> > (< 0 0) ,&< (1 0 ; 0 1) ....
> >
> >
> >
> >
> > ----- Original Message -----
> > From: Pascal Jasmin <[email protected]>
> > To: Programming Forum <[email protected]>
> > Sent: Wednesday, February 17, 2016 11:40 AM
> > Subject: [Jprogramming] an inverse to oblique
> >
> > </. i.5 5
> > +-+---+------+---------+------------+----------+--------+-----+--+
> > |0|1 5|2 6 10|3 7 11 15|4 8 12 16 20|9 13 17 21|14 18 22|19 23|24|
> > +-+---+------+---------+------------+----------+--------+-----+--+
> >
> > is there a way starting with the above boxes, to make the i. 5 5 table
> > (without relying on magic within the data)
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> 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