Thanks.  I'm beginning to see the connection to frequency distributions.

Linda

-----Original Message-----
From: programming-boun...@jsoftware.com 
[mailto:programming-boun...@jsoftware.com] On Behalf Of Raul Miller
Sent: Friday, December 09, 2011 1:21 PM
To: Programming forum
Subject: Re: [Jprogramming] Oblique Road to Success!

Here's a breakdown of how I wrote that.

First, consider how oblique works:

   </. i.3 4
+-+---+-----+-----+----+--+
|0|1 4|2 5 8|3 6 9|7 10|11|
+-+---+-----+-----+----+--+

It captures diagonals from a matrix.  And, also, it's J verb is
spelled the same as key -- so it would make sense if they were
related.  So, what would the key be?

This looks promising:
   (i.3) +/ i.4
0 1 2 3
1 2 3 4
2 3 4 5

So I am going to want to insert a verb between the first two elements
of the shape.
   3 +/&i. 4
0 1 2 3
1 2 3 4
2 3 4 5
   +/&i./ 3 4
0 1 2 3
1 2 3 4
2 3 4 5

Now I just need to ravel them and put the pieces together.  Oh, and I
also need to merge the first two dimensions of y so that key can work
properly:

   (,+/&i./ 2{. $y) u key ,/y

This works, but if I left it like this, I would have to add a comment
about how it does not work right when the argument (y) has less than
two dimensions.  2 {. $y will fill in 0s for those dimensions, and I
want 1s.  So I added a couple 1s so that those cases would work right.

-- 
Raul

On Fri, Dec 9, 2011 at 12:18 PM, Linda Alvord <lindaalv...@verizon.net> wrote:
> Where did you get this.  Is there some way that you capture code like this or 
> do you just write it yourself?
>
> oblique=:1 :0
>   (,+/&i./ 2{.1 1,~$y) u key ,/y
> )
>
> Thanks in advance.
>
> Linda
>
> -----Original Message-----
> From: programming-boun...@jsoftware.com 
> [mailto:programming-boun...@jsoftware.com] On Behalf Of Raul Miller
> Sent: Friday, December 09, 2011 11:09 AM
> To: Programming forum
> Subject: Re: [Jprogramming] Oblique Road to Success!
>
> On Fri, Dec 9, 2011 at 10:46 AM, Linda Alvord <lindaalv...@verizon.net> wrote:
>>     b=:5 3 5
>> Either definition has only one argument so isn't the function oblique rather
>> than key? So Ric has taken the "Oblique oad To Success!".  One wonders if it
>> is faster than the other one.
>
> My previous post about equivalents to /. was confused.
>
> /.~ uses key
> /. without ~ and using only one argument is oblique
>
> key=:1 :0
> :
>  (=x) u@#"1 _ y
> )
>
> oblique=:1 :0
>   (,+/&i./ 2{.1 1,~$y) u key ,/y
> )
>
> FYI,
>
> --
> Raul
> ----------------------------------------------------------------------
> 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