Re: [Jprogramming] Length of a vector

2013-12-15 Thread Ganesh Rapolu
en =. +/"1&.:*: On Sun, Dec 15, 2013 at 5:38 PM, km wrote: > This is an easy one, but let's see what you come up with. > > The Euclidian norm or length of a vector is the square root of the sum of > the squares of its components. Write verb en below. It should be able > to find the length o

Re: [Jprogramming] -: on empty arguments with differing types

2013-10-25 Thread Ganesh Rapolu
Upon further searching, I found http://www.jsoftware.com/pipermail/general/2005-November/025629.html, which seems to answer my question. On Fri, Oct 25, 2013 at 7:04 PM, Ganesh Rapolu wrote: > The dictionary does not say that the two arguments for -: have to match in > type so this res

[Jprogramming] -: on empty arguments with differing types

2013-10-25 Thread Ganesh Rapolu
The dictionary does not say that the two arguments for -: have to match in type so this result is correct. Nevertheless, I would be glad if someone could provide an explanation/justification for this behavior. datatype m =. 0 {. 'adaf' literal datatype n =. 0 {. 10 0 10 10 integer m -: n

Re: [Jprogramming] a more useful i. ?

2013-10-23 Thread Ganesh Rapolu
Oops. I meant 'array of boxes' instead of 'boxed arrays' in the second paragraph. On Wed, Oct 23, 2013 at 4:47 PM, Ganesh Rapolu wrote: > This new i. would be useful primarily on strings, where using symbols > instead already solves the problem more effectively. It mi

Re: [Jprogramming] a more useful i. ?

2013-10-23 Thread Ganesh Rapolu
This new i. would be useful primarily on strings, where using symbols instead already solves the problem more effectively. It might also slow down i. if it had to use another algorithm every time there was a mismatch in the lengths of the arguments. In K ragged arrays (called general lists) are l

Re: [Jprogramming] boxing the result of power

2013-10-22 Thread Ganesh Rapolu
<@(*/\.)\ 3 # 2 +-+---+--+ |2 |4 2|8 4 2| +-+---+--+ |. <\. */\. 3 # 2 +-+---+--+ |2 |4 2|8 4 2| +-+---+--+ On Mon, Oct 21, 2013 at 6:41 AM, Pascal Jasmin wrote: > probably more what you want: > > >>(#~ (a: ~: ])"0)each <"1 (+:@{.,])each ^:(<3) <2 > ┌─┬───┬─┐ > │2│

Re: [Jprogramming] converting excel column name to/from number

2013-10-20 Thread Ganesh Rapolu
NOPQRSTUVWXYZ' deb@:{~ (26)&#.^:_1) 26*2 > > BZ > > > > all the ones ending in Z are wrong. The pattern for correcting them is > to > > decrement letter for any preceding letter to Z except if preceeding is Z, > > and A becomes null. > > > > &g

Re: [Jprogramming] converting excel column name to/from number

2013-10-20 Thread Ganesh Rapolu
My previous solution fails for multiples of 26. Here is the corrected version. base26 =. 26&#. alph =. 'A' , a. {~ (a. i. 'A') + i.26 efn =. (base26^:_1) { alph"_ nfe =. [: base26 alph&i. efn 65535 CRXO nfe 'CRXO' 65535 efn 26 AA On Sun, Oct 20, 2013 at 4:13 PM, Pascal Jasm

Re: [Jprogramming] converting excel column name to/from number

2013-10-20 Thread Ganesh Rapolu
base26 =. 26&#. alph =. ' ' , a. {~ (a. i. 'A') + i.26 efn =. base26^:_1 { alph"_ nfe =. [: base26 alph&i. efn 65535 CRXO nfe 'CRXO' 65535 On Sun, Oct 20, 2013 at 3:52 PM, June Kim (김창준) wrote: > Hi > > A SW dev company posted its hiring post on its site and there is a coding

[Jprogramming] Odd timings for dyadic not (-.)

2013-10-12 Thread Ganesh Rapolu
m =. 1e6 ?@$ 1e6 n =. 5 ?@$ 1e6 f =. -.&n 10 ts 'm -. n' 0.0261088 9.43834e6 10 ts 'f m' 0.115288 8.39014e6 -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] memory mapped tab delimited file

2013-10-10 Thread Ganesh Rapolu
. safer for email secondcolumn =. (0;st;(< tab;LF))&;: NB. Boxed list of the second column (<'ABC') +/@:= secondcolumn mf On Thu, Oct 10, 2013 at 2:14 PM, Ganesh Rapolu wrote: > Assumptions: > - no double tabs > - no blank lines > - no blank columns > - no l

Re: [Jprogramming] memory mapped tab delimited file

2013-10-10 Thread Ganesh Rapolu
Assumptions: - no double tabs - no blank lines - no blank columns - no line starts with a tab - no column itself contains a tab - no CR - more than 2 columns - file is whole (rank 1 and not split by LF) st =. 1 0 , 0 6 ,: 0 0 st =. st ,: 0 6 , 0 6 ,: 2 1 st =. st , 3 3 , 0 6 ,: 2 0 st =. st , 3 0

Re: [Jprogramming] memory mapped tab delimited file

2013-10-10 Thread Ganesh Rapolu
Using a sequential machine to get the second column from the whole file and then doing the comparison might be faster. On Oct 10, 2013 9:23 AM, "Raul Miller" wrote: > When the size of your data exceeds some significant fraction of > available memory, it's probably worth using a loop. > > In other

Re: [Jprogramming] Slicing and dicing tables

2013-10-08 Thread Ganesh Rapolu
ta On Tue, Oct 8, 2013 at 4:41 AM, Ganesh Rapolu wrote: >names =. (header i. <'nameFirst') {"1 data >frequency =. #/.~ names >names =. ~. names >(10 = frequency) # names > +-+-+-+-+-+--+-+--++---+ &

Re: [Jprogramming] Slicing and dicing tables

2013-10-08 Thread Ganesh Rapolu
30) * (birthYears < 1950) * ( (names = <'Hank') + > >> > (names = <'Tommie'))) { data > >> > > >> > > >> > > >> > NB. http://www.jsoftware.com/jwiki/Essays/DataStructures > >> > > >> >

Re: [Jprogramming] Slicing and dicing tables

2013-10-07 Thread Ganesh Rapolu
; > Ok, now if I wanted to get counts for each name, I want to connect the > names from ~. (index {"1 data ) to the counting phrase Ganesh > provided: > > +/@:= index {"1 data -- but not sure how...? > > -Dan > > On Mon, Oct 7, 2013 at 2:04 PM, Dan Bron wrote:

Re: [Jprogramming] Slicing and dicing tables

2013-10-07 Thread Ganesh Rapolu
Because the data is boxed, all comparisons must be boxed. header =. {. data data =. }. data index =. header i. <'nameFirst' (<'Joe') +/@:= index {"1 data NB. 398 On Mon, Oct 7, 2013 at 10:25 AM, Marshall Lochbaum wrote: > You've got the arguments to i. backwards--the list to be searched is

Re: [Jprogramming] Possible error in the dictionary for dyadic take

2013-10-05 Thread Ganesh Rapolu
ally, if it says $$y or #$y. If it is correct, then it is not a > mistake. It is not to say that # and $ are interchangeable in all > situations. > > > > > On Sat, Oct 5, 2013 at 6:13 PM, Ganesh Rapolu wrote: > > > Brevity is not always conducive to understanding. I w

Re: [Jprogramming] Possible error in the dictionary for dyadic take

2013-10-05 Thread Ganesh Rapolu
> > On Sat, Oct 5, 2013 at 5:44 PM, Ganesh Rapolu wrote: > > > I am having difficulty finding reasons other than tradition that a length > > should be allowed to be a list. > > > > badlength =. $ > > mean =. +/ % badlength > > $ mean"1 i

Re: [Jprogramming] Possible error in the dictionary for dyadic take

2013-10-05 Thread Ganesh Rapolu
rrect mistakes made in APL by correcting the documentation for take. On Sat, Oct 5, 2013 at 2:19 PM, Roger Hui wrote: > It is traditional in APL (and APL-like) systems that a length is a list or > a scalar. > > > > On Sat, Oct 5, 2013 at 4:53 PM, Ganesh Rapolu wrote: > > > Al

Re: [Jprogramming] Possible error in the dictionary for dyadic take

2013-10-05 Thread Ganesh Rapolu
y or #$y are correct in this case. > > > > On Sat, Oct 5, 2013 at 4:14 PM, Ganesh Rapolu wrote: > > > In the last paragraph, $$y should be #$y. > > -- > > For informatio

[Jprogramming] Possible error in the dictionary for dyadic take

2013-10-05 Thread Ganesh Rapolu
In the last paragraph, $$y should be #$y. -- For information about J forums see http://www.jsoftware.com/forums.htm