Re: [Jprogramming] rank trouble

2012-06-02 Thread Linda Alvord
...@jsoftware.com [mailto:programming-boun...@jsoftware.com] On Behalf Of Alexander Mikhailov Sent: Friday, June 01, 2012 1:35 PM To: programming@jsoftware.com Subject: Re: [Jprogramming] rank trouble - Without the nub gives an arguably more correct answer: pi (]-.]-.[) e 2 1 2 1 3 e

Re: [Jprogramming] rank trouble

2012-06-02 Thread R.E. Boss
(20 $])~ pi 3 3 1 1 1 1 2 2 R.E. Boss -Oorspronkelijk bericht- Van: programming-boun...@jsoftware.com [mailto:programming-boun...@jsoftware.com] Namens Linda Alvord Verzonden: zaterdag 2 juni 2012 11:24 Aan: 'Programming forum' Onderwerp: Re: [Jprogramming] rank trouble

Re: [Jprogramming] rank trouble

2012-06-01 Thread Devon McCormick
You could also do this: e ([:~.]-.]-.[) pi 3 1 2 pi ([:~.]-.]-.[) e 2 1 3 Without the nub gives an arguably more correct answer: pi (]-.]-.[) e 2 1 2 1 3 e (]-.]-.[) pi 3 1 1 2 /:~1 e,:pi 1 1 2 2 3 7 8 8 8 1 1 2 3 4 5 5 6 9 On Thu, May 31, 2012 at 10:48 AM, Graham Parkhouse

Re: [Jprogramming] rank trouble

2012-06-01 Thread Alexander Mikhailov
- Without the nub gives an arguably more correct answer: pi (]-.]-.[) e 2 1 2 1 3 e (]-.]-.[) pi 3 1 1 2 - Why not e ([ -. -.) pi 2 1 2 1 3 ? -- For information about J forums see

Re: [Jprogramming] rank trouble

2012-06-01 Thread Graham Parkhouse
Thank you Devon and Alexander! -. does intersection most elegantly. I shall use it. On Fri, 1 Jun 2012 12:50:43 -0400 Devon McCormick devon...@gmail.com wrote: You could also do this: e ([:~.]-.]-.[) pi 3 1 2 pi ([:~.]-.]-.[) e 2 1 3 Without the nub gives an

[Jprogramming] rank trouble

2012-05-31 Thread Graham Parkhouse
Can anyone help me to understand where I am going wrong? e=: 2 7 1 8 2 8 1 8 3 pi=: 3 1 4 1 5 9 2 6 5 isecn=: ([: /:~ [: ~. e. # [)1 NB. Intersection of the two sets e isecn pi 1 2 3 pi isecn e 1 2 3 isecn/ e,:pi 1 2 3 isecn/1 e,.pi This last sentence give me 9

Re: [Jprogramming] rank trouble

2012-05-31 Thread Raul Miller
On Thu, May 31, 2012 at 10:48 AM, Graham Parkhouse graham.parkho...@ntlworld.com wrote:   e=: 2 7 1 8 2 8 1 8 3   pi=: 3 1 4 1 5 9 2 6 5   isecn=: ([: /:~ [: ~. e. # [)1     NB. Intersection of the two sets ...   isecn/1 e,.pi This last sentence give me 9 blank lines. I expected and

Re: [Jprogramming] rank trouble

2012-05-31 Thread David Mitchell
Perhaps this will help: e=: 2 7 1 8 2 8 1 8 3 pi=: 3 1 4 1 5 9 2 6 5 e,.pi 2 3 7 1 1 4 8 1 2 5 8 9 1 2 8 6 3 5 ]/1 e,.pi 3 1 4 1 5 9 2 6 5 [/1 e,.pi 2 7 1 8 2 8 1 8 3 On 5/31/2012 10:48, Graham Parkhouse wrote: Can anyone help me to understand where I am going wrong?

Re: [Jprogramming] rank trouble

2012-05-31 Thread Kip Murray
isecn/ y inserts verb isecn between the items of y Consider |: e ,. pi NB. items are e and pi 2 7 1 8 2 8 1 8 3 3 1 4 1 5 9 2 6 5 isecn/ |: e ,. pi 1 2 3 On 5/31/2012 9:48 AM, Graham Parkhouse wrote: Can anyone help me to understand where I am going wrong? e=: 2 7 1 8

Re: [Jprogramming] rank trouble

2012-05-31 Thread Graham Parkhouse
Thank you everybody! I was just thinking that, using 1, I was just swapping rows for columns - sloppy thinking; transpose is indeed necessary! Using [ and ] as test functions on structure is very helpful, like using to demonstrate partitioning conjunctions. Regards Graham On Thu, May 31, 2012

Re: [Jprogramming] rank question

2011-11-18 Thread Raul Miller
I have been trying to think up a useful response here, but I just do not know enough from this description to make good choices. Typically, I build up the expressions that I find useful first and then come up with names for them later. Sometimes I re-arrange things that work so that they are

Re: [Jprogramming] rank question

2011-11-18 Thread Daniel Lyons
Raul, On Fri, Nov 18, 2011 at 12:02:47PM -0500, Raul Miller wrote: I have been trying to think up a useful response here, but I just do not know enough from this description to make good choices. Well, I appreciate the attempt. :) I don't know enough to know what information would be necessary

Re: [Jprogramming] rank question

2011-11-18 Thread Raul Miller
I think that representative data, along with a description of the result and purpose of the code would work. (Or, if not, that should be enough for us to ask intelligent questions.) -- Raul On Fri, Nov 18, 2011 at 12:45 PM, Daniel Lyons fus...@storytotell.orgwrote: Raul, On Fri, Nov 18,

Re: [Jprogramming] rank question

2011-11-18 Thread Daniel Lyons
On Fri, Nov 18, 2011 at 12:49:55PM -0500, Raul Miller wrote: I think that representative data, along with a description of the result and purpose of the code would work. (Or, if not, that should be enough for us to ask intelligent questions.) I've been disinclined to share the problem because

Re: [Jprogramming] rank question

2011-11-18 Thread Daniel Lyons
Raul, On Fri, Nov 18, 2011 at 03:53:07PM -0500, Raul Miller wrote: Ok.. I hope we have not ruined anything here (to prevent people from googling this and studying up ahead of time, it would be best if the terminology were somewhat obfuscated). But, anyways... I don't think it will be a

Re: [Jprogramming] rank question

2011-11-18 Thread Raul Miller
I did not see anything attached, but forgot about that before I was ready to reply. And here's an overview of how I treated angle differences: degdif/~ 0 90 180 270 360 0 _90 _180 900 900 _90 _180 90 _180 900 _90 _180 _90 _180 900 _90 0 _90 _180 900

Re: [Jprogramming] rank question

2011-11-18 Thread Daniel Lyons
On Fri, Nov 18, 2011 at 04:34:24PM -0500, Raul Miller wrote: I did not see anything attached, but forgot about that before I was ready to reply. It looks like the mailing list has stripped the attachments. -- Daniel Lyons --

Re: [Jprogramming] rank question

2011-11-17 Thread Raul Miller
In general, structuring J code is an exercise in picking the right words. That said, in this case: adding 1 on a verb that assumes a rank 1 argument is only meaningful for verbs which do the right thing on equal length arguments. -- Raul On Wed, Nov 16, 2011 at 11:36 PM, Daniel Lyons

Re: [Jprogramming] rank question

2011-11-17 Thread Björn Helgason
I think that people very often misunderstand what they are doing when setting/changing rank. I very rarely see people set more than one number after the as in 1 and on an occasion 0 1 and not realizing that you actually need three numbers to set the ranks when the ranks are for a dyadic verb.

Re: [Jprogramming] rank question

2011-11-17 Thread Kip Murray
From the Vocabulary page on Rank un The verb un applies u to each cell as specified by the rank n . The full form of the rank used is 3$.|.n . For example, if n=:2 , the three ranks are 2 2 2 , and if n=: 2 3, they are 3 2 3 . On 11/17/2011 9:13 AM, Björn Helgason wrote: I think that people

Re: [Jprogramming] rank question

2011-11-17 Thread Daniel Lyons
On Thu, Nov 17, 2011 at 09:49:32AM -0500, Raul Miller wrote: In general, structuring J code is an exercise in picking the right words. Well, in case you can help with that, here's my situation. For this particular problem, I need to calculate a distance, so I have an origin and a destination.

Re: [Jprogramming] rank question

2011-11-16 Thread Devon McCormick
Since you know you want the function to applied with rank 1, you should probably build it into the definition, e.g. timeToMove=: ((timeToRotate : azimuth) . (timeToAscend : elevation))1 left timeToMove right 0.15 0.45 1.15 On Tue, Nov 15, 2011 at 9:39 AM, Daniel Lyons

Re: [Jprogramming] rank question

2011-11-16 Thread Daniel Lyons
On Nov 16, 2011, at 8:49 AM, Devon McCormick wrote: Since you know you want the function to applied with rank 1, you should probably build it into the definition, e.g. timeToMove=: ((timeToRotate : azimuth) . (timeToAscend : elevation))1 left timeToMove right 0.15 0.45 1.15 I

Re: [Jprogramming] rank question

2011-11-15 Thread Kip Murray
I cannot duplicate your error. From your definitions I get left timeToMove right 0.25 0.45 You might notice left 0 1 2 3 4 5 elevation left 2 3 elevation1 left 1 3 5 Which do you want? On 11/15/2011 1:08 AM, Daniel Lyons wrote: I suspect this is a classic beginner misstep,

Re: [Jprogramming] rank question

2011-11-15 Thread Raul Miller
I cannot duplicate it either. I suspect that a definition which is different from what was posted. -- Raul On Tue, Nov 15, 2011 at 7:27 AM, Kip Murray k...@math.uh.edu wrote: I cannot duplicate your error.  From your definitions I get    left timeToMove right 0.25 0.45 You might notice

Re: [Jprogramming] rank question

2011-11-15 Thread Daniel Lyons
On Nov 15, 2011, at 5:27 AM, Kip Murray wrote: I cannot duplicate your error. Trying it again this morning, I see I must have had a bad definition in my session. Loading from the file I get the same behavior as you and Raul. Sorry about that! From your definitions I get left

[Jprogramming] rank question

2011-11-14 Thread Daniel Lyons
I suspect this is a classic beginner misstep, but I don't see what I'm doing wrong. I have a verb which doesn't work unless I use the rank-1 adverb. Here are the definitions: diff =: -`(-~) @. azimuth =: 0 {:: elevation =: 1 {:: minRotationDistance =: - . : (360|) -~ timeToRotate =:

Re: [Jprogramming] rank newbie question

2011-06-09 Thread Ian Clark
Becomes even clearer if you define: plus=: (4 : '(:x),''+'',(:y)')0 plus/a ┌───┬───┬───┬───┐ │0+8+16 │1+9+17 │2+10+18│3+11+19│ ├───┼───┼───┼───┤ │4+12+20│5+13+21│6+14+22│7+15+23│ └───┴───┴───┴───┘ plus/1 a ┌───┬───┐ │0+1+2+3

[Jprogramming] rank newbie question

2011-06-08 Thread Squint6
Hi, I have just started with J and I have a question concerning rank (I think). I don't understand why the following does what it does: a=. 2 2 $ i.4 b=.+/a c=.+/1 a After executing these lines a contains 0 1 2 3 b contains 2 4 and c contains 1 5 I understand where b is coming

Re: [Jprogramming] rank newbie question

2011-06-08 Thread Henry Rich
You almost had it. I've fixed the error below. Henry Rich On 6/8/2011 5:41 PM, Squint6 wrote: Hi, I have just started with J and I have a question concerning rank (I think). I don't understand why the following does what it does: a=. 2 2 $ i.4 b=.+/a c=.+/1 a After executing

Re: [Jprogramming] rank newbie question

2011-06-08 Thread Dan T. Abell
On 8 Jun 2011, at 15:41, Squint6 wrote: a=. 2 2 $ i.4 b=.+/a c=.+/1 a After executing these lines a contains 0 1 2 3 b contains 2 4 and c contains 1 5 I understand where b is coming from but c's value confuses me. Here's how my (faulty) reasoning about c=.+/1 a goes.

Re: [Jprogramming] rank newbie question

2011-06-08 Thread Ian Clark
Thank you, Kent, for posing a newbie question that crystallises the essence of Rank (). And thanks to those who've offered an answer. I was just about to supply the content for the NuVoc entry on Rank: http://www.jsoftware.com/jwiki/Vocabulary/quote Your micro-example spotlights exactly what a

[Jprogramming] rank newbie question

2011-06-08 Thread Squint6
Thanks for the answers, Henry and Dan. It seems kind of obvious now, but it had me scratching my head before you enlightened me. Ian, always glad when my ignorance can be of service. Kent. -- For information about J forums

Re: [Jprogramming] rank newbie question

2011-06-08 Thread Randy MacDonald
I wonder how the following is explained with rank: i. 2 2 ┌───┐ │0 1│ │2 3│ └───┘ 1 i. 2 2 ┌───┬───┐ │0 1│2 3│ └───┴───┘ The posted explanations seem to be missing something... On 6/8/2011 11:21 PM, Ian Clark wrote: Thank you, Kent, for posing a newbie question that crystallises the essence

Re: [Jprogramming] rank newbie question

2011-06-08 Thread Ian Clark
Thanks for pointing out that Dic explains it better than Voc. I accept unreservedly that there is no shortage of documentation on Rank, and that it is adequately explained somewhere. But let's ask: is the delivery of this material effective? ...No, I can't answer that. It takes an articulate J

Re: [Jprogramming] rank newbie question

2011-06-08 Thread Ian Clark
Ian, always glad when my ignorance can be of service. You may laugh, but articulate ignorance is a precious commodity. A perishable one. On Thu, Jun 9, 2011 at 3:54 AM, Squint6 squi...@aol.com wrote: Thanks for the answers, Henry and Dan.  It seems kind of obvious now, but it had me

Re: [Jprogramming] rank newbie question

2011-06-08 Thread Ric Sherlock
The default rank of the monadic verb (Box) is infinite so it will operate on the whole of its right argument at once. Hence: i. 2 2 +---+ |0 1| |2 3| +---+ by adding 1 to the verb we are feeding the argument to the verb a 1-cell at-a-time. As has already been shown, the 1-cells of ( i.2 2 )

Re: [Jprogramming] rank newbie question

2011-06-08 Thread Kip Murray
A source of confusion for a newcomer can be that the items of an array are shown in a vertical list except when the array is a vector the items are shown in a horizontal list. Thus in the array ]a =: 3 2 4 $ i. 24 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

Re: [Jprogramming] Rank zero append (,0)

2010-08-29 Thread Graham Parkhouse
Thank you R.E. Boss and Brian. The reference material is so good. Yes, I'm clearer on agreement now. And I'm not sure it's worth troubling you all with this, but my underlying problem was linked with the empty vector. What I was wanting was a verb c with these properties: 0 1 c 0 1 2 0 0 0 1 0

[Jprogramming] Rank zero append (,0)

2010-08-28 Thread Graham Parkhouse
'',1 2 3 1 2 3 NB. OK '',0 [1 2 3 |length error | '',0[1 2 3 NB. Is this because there are NO atoms in LH argument? NB. I would have preferred to have seen 1 2 3 1 2 3,0/ 4 5 6 1 4 1 5 1 6 2 4 2 5 2 6 3 4 3 5 3 6 NB. OK '',0/ 4 5 6 NB. I would have preferred to

Re: [Jprogramming] Rank zero append (,0)

2010-08-28 Thread R.E. Boss
Parkhouse Verzonden: zaterdag 28 augustus 2010 12:32 Aan: programming@jsoftware.com Onderwerp: [Jprogramming] Rank zero append (,0) '',1 2 3 1 2 3 NB. OK '',0 [1 2 3 |length error | '',0[1 2 3 NB. Is this because there are NO atoms in LH argument? NB. I would have

Re: [Jprogramming] Rank zero append (,0)

2010-08-28 Thread Brian Schott
I find your explanation very helpful, especially because of the links you have given to the primer, which I had not studied carefully. Refer to the following link, please, where we read, For a dyad the left rank of the verb and the rank of the left argument determine the frame of the left

Re: [Jprogramming] Rank zero append (,0)

2010-08-28 Thread Brian Schott
I see that the example I meant to show literal arguments was not included so I am adding it now, though it is certainly not noteworthy. ''(,0) frame '123' ┌─┬─┐ │0│3│ └─┴─┘ And the next examples show a monadic verb and a dyadic verb with literal arguments.   + frame 2 3 4 ┌─┐ │3│

Re: [Jprogramming] Rank amateur question

2010-03-19 Thread bill lam
ĵaŭ, 18 Mar 2010, Zsbán Ambrus skribis: 2010/3/18 Frederick W Mellem mell...@frontiernet.net:   i..(0) 4 2 3 T---T-┐ │0 1 2 3       │0 1   │0 1 2     │ L---+---+--   i..(0) 4 2 3 --T-T-T-┐ │0 │1 │2 │3 │ +-+-+-+-+ │0 │1 │  │   │ +-+-+-+-+

[Jprogramming] Rank amateur question

2010-03-18 Thread Frederick W Mellem
i.. 4 2 3 T---T-┐ │0 1 2 3 │0 1 │0 1 2 │ L---+---+-- i..(0) 4 2 3 T---T-┐ │0 1 2 3 │0 1 │0 1 2 │ L---+---+-- i..(0) 4 2 3 --T-T-T-┐ │0 │1 │2 │3 │ +-+-+-+-+ │0 │1 │ │ │ +-+-+-+-+ │0 │1│2 │ │ L-+-+-+--

Re: [Jprogramming] Rank amateur question

2010-03-18 Thread Zsbán Ambrus
2010/3/18 Frederick W Mellem mell...@frontiernet.net:   i..(0) 4 2 3 T---T-┐ │0 1 2 3       │0 1   │0 1 2     │ L---+---+--   i..(0) 4 2 3 --T-T-T-┐ │0 │1 │2 │3 │ +-+-+-+-+ │0 │1 │  │   │ +-+-+-+-+ │0  │1│2 │  │ L-+-+-+-- Please explain the scalar

Re: [Jprogramming] Rank amateur question

2010-03-18 Thread Bo Jacoby
Hi Frederick Because    i..(0) 4 2 3 means   (i..)(0) 4 2 3 - Bo --- Den tors 18/3/10 skrev Frederick W Mellem mell...@frontiernet.net: Fra: Frederick W Mellem mell...@frontiernet.net Emne: [Jprogramming] Rank amateur question Til: programming@jsoftware.com Dato: torsdag 18. marts 2010 22.48

[Jprogramming] Rank is nice!

2010-03-16 Thread Sherlock, Ric
I was revisiting some code from a few years ago when I was first coming to grips with J. It basically reformats a table formatted with one column per variable for each record (spreadsheet format) to having one record for each variable (database format). ]tst=: (;:'tag yr weight dob') , 0 i.

Re: [Jprogramming] rank by a key

2009-11-13 Thread Tirrell, Jordan (Consultant)
: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

Re: [Jprogramming] rank by a key

2009-11-13 Thread Raul Miller
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,

Re: [Jprogramming] rank by a key

2009-11-13 Thread Tirrell, Jordan (Consultant)
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

[Jprogramming] rank by a key

2009-11-10 Thread Tirrell, Jordan (Consultant)
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

Re: [Jprogramming] rank by a key

2009-11-10 Thread Raul Miller
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

Re: [Jprogramming] rank by a key

2009-11-10 Thread neitzel
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

Re: [Jprogramming] rank by a key

2009-11-10 Thread R.E. Boss
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.~\:~)/.) \:

Re: [Jprogramming] Rank problem

2009-02-18 Thread Björn Helgason
Is this what you wanted? $('abc')=.4 2 7 3 9 5 or this? $('a b c')=.4 2 7 2009/2/18 David Vincent-Jones davidvincentjo...@gmail.com OK .. I know this is a rank problem but I still have difficulties understanding how to solve this simple question. ($'abc')=4 2 7 3 9 |length error |

Re: [Jprogramming] Rank problem

2009-02-18 Thread Roger Hui
The result of $ in this case is a one-element vector, which is a mismatch with a 5-element vector. You can use # instead of $ . - Original Message - From: David Vincent-Jones davidvincentjo...@gmail.com Date: Wednesday, February 18, 2009 11:55 Subject: [Jprogramming] Rank problem

Re: [Jprogramming] Rank problem

2009-02-18 Thread David Vincent-Jones
- From: David Vincent-Jones davidvincentjo...@gmail.com Date: Wednesday, February 18, 2009 11:55 Subject: [Jprogramming] Rank problem To: JSoftware programming@jsoftware.com OK .. I know this is a rank problem but I still have difficulties understanding how to solve this simple question

Re: [Jprogramming] Rank problem

2009-02-18 Thread Roger Hui
18, 2009 12:32 Subject: Re: [Jprogramming] Rank problem To: Programming forum programming@jsoftware.com Thank you .. yes # is what I should have used ... obvious in hindsight. David On Wed, 2009-02-18 at 12:04 -0800, Roger Hui wrote: The result of $ in this case is a one-element vector

Re: [Jprogramming] Rank problem with Table

2008-10-29 Thread Raul Miller
On Wed, Oct 29, 2008 at 8:17 PM, June Kim [EMAIL PROTECTED] wrote: I was surprised since I originally thought the result of (1 + *)/ should be instead: 1 1 1 1 2 3 1 3 5 (1+*)0/~i.3 1 1 1 1 2 3 1 3 5 From the dictionary: In general, each cell of x is applied to the entire of y

[Jprogramming] rank with Bond

2008-03-06 Thread Brian Schott
Can somebody tell me how to get the following behavior that does not use Bond but with Bond. $(3 3$0 0 0 0 2 0 0 0 0)|. _1 i. 3 4 5 3 3 4 5 3 $(3 3$0 0 0 0 2 0 0 0 0)|.1 _1 i. 3 4 5 3 3 4 5 3 $(3 3$0 0 0 0 2 0 0 0 0)|.1 _1 _1 i. 3 4 5 3 3 4 5 3 When I use Bond as below

Re: [Jprogramming] rank with Bond

2008-03-06 Thread Raul Miller
On 3/6/08, Brian Schott [EMAIL PROTECTED] wrote: Can somebody tell me how to get the following behavior that does not use Bond but with Bond. $(3 3$0 0 0 0 2 0 0 0 0)|. _1 i. 3 4 5 3 3 4 5 3 The verb you want to bond with is |._1 In your example, you were bonding with the verb |.

[Jprogramming] Rank Question when using +/

2008-02-18 Thread Leigh J. Halliwell
Dear J Forum: I am applying +/ to arrays that can be of either rank 1 or rank 2. The following approach works fine for rank 2: +/ i. 2 5 5 7 9 11 13 But for a rank 1 array, I want just the array itself. I can do that with +/_1: +/_1 i. 5 0 1 2 3 4 However +/_1 i.2 5 collapses along

Re: [Jprogramming] Rank Question when using +/

2008-02-18 Thread Brian Schott
In validate.ijs find ismatrix. (Or change = to :) ismatrix=: 2 = [EMAIL PROTECTED] ]`(+/)@.ismatrix i. 2 5 5 7 9 11 13 ]`(+/)@.ismatrix i. 5 0 1 2 3 4 ]`(+/)@.ismatrix 5 5 On Mon, 18 Feb 2008, Leigh J. Halliwell wrote: + Dear J Forum: + + I am applying +/ to arrays that

Re: [Jprogramming] Rank Question when using +/

2008-02-18 Thread Raul Miller
Other possibilities: +/_1@|: +/@(,:^:([EMAIL PROTECTED])) +/^:(1 [EMAIL PROTECTED]) FYI, -- Raul -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Rank Question when using +/

2008-02-18 Thread Devon McCormick
Either of these: +./1 i. 2 5 5 7 9 11 13 +./1 i. 5 0 1 2 3 4 dos=: ] ` (+/) @. (2=[:#$) dos i. 5 0 1 2 3 4 dos i. 2 5 5 7 9 11 13 The latter is probably more efficient. On 2/18/08, Leigh J. Halliwell [EMAIL PROTECTED] wrote: Dear J Forum: I am applying +/ to arrays that can

Re: [Jprogramming] Rank of ,.

2008-02-16 Thread Roger Hui
Message - From: Joey K Tuttle [EMAIL PROTECTED] Date: Friday, February 15, 2008 22:12 Subject: Re: [Jprogramming] Rank of ,. To: Programming forum programming@jsoftware.com Better to ask what version of J. Interesting change between j504 and j601 - more fodder to chew... version '' j504

Re: [Jprogramming] Rank Question

2008-02-16 Thread Raul Miller
Rank 1 verbs treat rows as items. Transpose turns columns into rows. Adverse lets you try one thing and if that fails try the other. So I suspect that this might work: nfpt2 ::nfpt1 |: csvdata -- Raul -- For information

Re: [Jprogramming] Rank of ,.

2008-02-16 Thread neitzel
Joey K Tuttle: Better to ask what version of J. Indeed. Somehow this expression was too cute to be true... I fixed my version now. Thanks to Roger for the step-by-step equivalency which was helpful in chasing out the bug quickly. neitzel 8 jfront -q $ 'abc' ,. . ,. '123' 3 2 9!:14''

Re: [Jprogramming] Rank of ,.

2008-02-15 Thread Raul Miller
On Fri, Feb 15, 2008 at 2:26 AM, Yoel Jacobsen [EMAIL PROTECTED] wrote: a ,@,.(0 _) b Note that this gives the same result for your sample data: a ,@,0 _ b -- Raul -- For information about J forums see

Re: [Jprogramming] Rank of ,.

2008-02-15 Thread Devon McCormick
,2 a,0/b 1 10 1 20 1 30 2 10 2 20 2 30 3 10 3 20 3 30 -- Devon McCormick, CFA ^me^ at acm. org is my preferred e-mail -- For information about J forums see http://www.jsoftware.com/forums.htm

RE: [Jprogramming] Rank Question

2008-02-15 Thread Lettow, Kenneth
(reformatted the original) Hi, I have a question about composing functions. I have the following scenario. 1. I read in a csv file. 2. I split the array its constituent columns. 3. The columns are a mix of text and number data. 4. I wrote two verbs that gives me the nub, frequency, and

RE: [Jprogramming] Rank Question

2008-02-15 Thread Sherlock, Ric
February 2008 10:56 To: Programming forum Subject: RE: [Jprogramming] Rank Question (reformatted the original) Hi, I have a question about composing functions. I have the following scenario. 1. I read in a csv file. 2. I split the array its constituent columns. 3. The columns

Re: [Jprogramming] Rank of ,.

2008-02-15 Thread neitzel
Yoel Jacobsen programming@jsoftware.com wrote: I have experimented with ,. and ,: without success. What did I miss? . a ,. . ,. b 1 10 1 20 1 30 2 10 2 20 2 30 3 10 3 20 3 30 Martin

RE: [Jprogramming] Rank Question

2008-02-15 Thread Brian Schott
I am not sure this is what you want but, for the common parts of the two verbs I think you can use the following. (@#/.~) NB. for frequency (#/.~ @% # ) NB. for % + + nfpt=:([: 1 ~.) ,. ([: 0 #/.~) ,. [: 0 #/.~ % # NB. For Text columns + nfpt2=:([: 0 ~.) ,. ([: 0 #/.~) ,. [: 0

Re: [Jprogramming] Rank of ,.

2008-02-15 Thread Joey K Tuttle
Better to ask what version of J. Interesting change between j504 and j601 - more fodder to chew... version '' j504/2005-03-16/15:30 Running in: Linux Linux version 2.4.20-28.8 ([EMAIL PROTECTED]) (gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)) #1 Thu Dec 18 12:53:39 EST 2003 1 2 3

[Jprogramming] Rank of ,.

2008-02-14 Thread Yoel Jacobsen
How can I append each element of the RHS list to each element of the LHS list? Example: a =. 1 2 3 b =. 10 20 30 I would like a to achieve: a something b that will result in: 1 10 1 20 1 30 2 10 2 20 2 30 3 10 3 20 3 30 I have experimented with ,. and ,: without success. What did I miss?

Re: [Jprogramming] Rank of ,.

2008-02-14 Thread Yoel Jacobsen
Thank you. I eventually did this: a ,@,.(0 _) b Yoel On Fri, Feb 15, 2008 at 9:18 AM, Chris Burke [EMAIL PROTECTED] wrote: Yoel Jacobsen wrote: How can I append each element of the RHS list to each element of the LHS list? Example: a =. 1 2 3 b =. 10 20 30 I would

Re: [Jprogramming] Rank of ,.

2008-02-14 Thread Chris Burke
Yoel Jacobsen wrote: How can I append each element of the RHS list to each element of the LHS list? Example: a =. 1 2 3 b =. 10 20 30 I would like a to achieve: a something b that will result in: 1 10 1 20 1 30 2 10 2 20 2 30 3 10 3 20 3 30 If you append each element of the RHS to each

[Jprogramming] Rank of rotate

2007-09-13 Thread R.E. Boss
To rotate a matrix by its axes separately one does (=i.2)|.i.3 4 4 5 6 7 8 9 10 11 0 1 2 3 1 2 3 0 5 6 7 4 9 10 11 8 This works as expected. However (=i.2)|.2 i.3 4 5 |length error | (=i.2)|.2 i.3 4 5 This is strange, since it should be equal to (=i.2)|.2 i.3 4

RE: [Jprogramming] Rank of rotate

2007-09-13 Thread R.E. Boss
13 september 2007 8:22 Aan: 'Programming forum' Onderwerp: [Jprogramming] Rank of rotate To rotate a matrix by its axes separately one does (=i.2)|.i.3 4 4 5 6 7 8 9 10 11 0 1 2 3 1 2 3 0 5 6 7 4 9 10 11 8 This works as expected. However (=i.2)|.2 i.3 4 5

Re: [Jprogramming] Rank of rotate

2007-09-13 Thread Raul Miller
On 9/13/07, R.E. Boss [EMAIL PROTECTED] wrote: (=i.2)|.2 i.3 4 5 |length error | (=i.2)|.2 i.3 4 5 ... What's wrong? Looks like a bug. Replacing |. with a functionally equivalent verb (such as |.]) works. -- Raul

Re: [Jprogramming] Rank of rotate

2007-09-13 Thread Roger Hui
The second expression should not have signalled error. This bug has now been fixed for the next release. Thank you for finding and reporting it. - Original Message - From: R.E. Boss [EMAIL PROTECTED] Date: Wednesday, September 12, 2007 23:22 Subject: [Jprogramming] Rank of rotate

[Jprogramming] Rank of u.v

2006-07-19 Thread Samuel Tardieu
http://www.jsoftware.com/books/help/dictionary/d300.htm states that the rank of u.v is 2 _ _ However: (+/.*) b. 0 _ _ _ -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Rank of u.v

2006-07-19 Thread John Randall
Samuel Tardieu wrote: http://www.jsoftware.com/books/help/dictionary/d300.htm states that the rank of u.v is 2 _ _ However: (+/.*) b. 0 _ _ _ (+/ .*) b. 0 2 _ _ +/.* +/. * John -- For information about J

Re: [Jprogramming] Rank of u.v

2006-07-19 Thread Samuel Tardieu
John == John Randall [EMAIL PROTECTED] writes: John(+/ .*) b. 0 John 2 _ _ Ooops :-) -- For information about J forums see http://www.jsoftware.com/forums.htm

[Jprogramming] Rank and Sort on a Specific Column

2006-05-08 Thread June Kim
Hello Firstly, have a look at my quick and dirty code: t=: 0 : 0 1 aaa 10 0.2 2 bbb 2 1 3 ccc 5 5 4 ddd 22 0.987 5 eee 1 0.987 6 fff 100 1 7 ggg 20 0.4 ) t2=:;:;._2 r=:] i.~ [: ~. \:~ keyf=:[: {:1 @(.each)@ {:1 tt=:keyf (\:@[ { :each@(0)@:@[EMAIL PROTECTED] ,. ]) ] sp=: [ , ' ' , ]

[Jprogramming] Rank of Evoke Gerund

2006-04-05 Thread Fred Bone
The Vocabulary page for Evoke Gerund says, for the first defined case: m `: 0Append Appends the results of the individual verbs; the ranks are the maxima over their ranks The second example given (+ b.0) ; (%. b.0) ; (+`%.`:0 b.0) +-+-+-+ |0 0 0|2 _ 2|_ _

Re: [Jprogramming] Rank of Evoke Gerund

2006-04-05 Thread Roger Hui
Subject: [Jprogramming] Rank of Evoke Gerund The Vocabulary page for Evoke Gerund says, for the first defined case: m `: 0 Append Appends the results of the individual verbs; the ranks are the maxima over their ranks The second example given (+ b.0) ; (%. b.0) ; (+`%.`:0 b.0