:25 PM
To: programming@jsoftware.com
Subject: Re: [Jprogramming] rank by a key
In the following example, collection 0 is 10 30 20 20 and has ranks 3
0
1 1, while collection 1 is 200 100 300 and has ranks 1 2 0. The
problem
is the extra 0 appended to make them the same size, [...]
The usual way
On Fri, Nov 13, 2009 at 1:10 PM, Tirrell, Jordan (Consultant) key=:
1 1,1 0,1 1,1 0,1 0,0 1,:1 1
data=: 0 1,1 1,0 2,0 2,2 0,0 0,:1 1
key rankbykey1 data
2 1 1 2 0 0 0
key rankbykey2 data
2 1 1 2 0 0 0
I cannot figure out how to use ~: to express this function as Raul
Miller suggested,
It works great, and in a few seconds less.
Thanks!
Jordan
-Original Message-
From: programming-boun...@jsoftware.com
[mailto:programming-boun...@jsoftware.com] On Behalf Of Raul Miller
Sent: Friday, November 13, 2009 2:34 PM
To: Programming forum
Subject: Re: [Jprogramming] rank
Given a key (in the sense of /.), I'd like to obtain the rank (the
i.~\:~ kind, not the kind) of each item within the collection
corresponding to its key. My first instinct was to try (i.~\:~)/. but
this is not exactly what I want.
In the following example, collection 0 is 10 30 20 20 and has
On Tue, Nov 10, 2009 at 4:23 PM, Tirrell, Jordan (Consultant)
jtirr...@thomasnet.com wrote:
Given a key (in the sense of /.), I'd like to obtain the rank (the
i.~\:~ kind, not the kind) of each item within the collection
corresponding to its key. My first instinct was to try (i.~\:~)/. but
In the following example, collection 0 is 10 30 20 20 and has ranks 3 0
1 1, while collection 1 is 200 100 300 and has ranks 1 2 0. The problem
is the extra 0 appended to make them the same size, [...]
The usual way to avoid those extra fills is to box the interim values
and to flatten
i.~ 8 4 4 4 8 8 8
0 1 1 1 0 0 0
8 4 4 4 8 8 8 (;@(@(i.~\:~)/.) /: i...@[) 10 200 100 300 30 20 20
3 1 2 0 0 1 1
All in all, this is not very different from what you did. Slighltly
less boxing/unboxing. Can you measure any difference?
or
8 4 4 4 8 8 8 (;@(@(i.~\:~)/.) \: