Re: [Jprogramming] converting numbers and rank trouble

2018-04-13 Thread Joe Bogner
Nice - I didn't realize dyalog had a blog. Looks like great content. It may be time to finally learn a bit of APL to have a passing reading comprehension in it. I have stopped and started the Dyalog book a few times over the years as I have wanted to digest some of the Essays but that is probably

Re: [Jprogramming] converting numbers and rank trouble

2018-04-13 Thread Joe Bogner
Sorry for the confusion. Yes, it is a character matrix. In this case it is a text file with one line per numeric value that is read with fread. I don't box the values I was using boxed arrays as a shorthand to create the character matrix sample. I find it easier sometimes to do that for sample -

Re: [Jprogramming] converting numbers and rank trouble

2018-04-13 Thread Raul Miller
Not nested boxes (for example). But point taken. Thanks, -- Raul On Fri, Apr 13, 2018 at 6:11 PM, Roger Hui wrote: > They do _under_ conversion to numbers and under open. > > > > On Fri, Apr 13, 2018 at 2:49 PM, Raul Miller wrote: > >> I

Re: [Jprogramming] converting numbers and rank trouble

2018-04-13 Thread Roger Hui
They do _under_ conversion to numbers and under open. On Fri, Apr 13, 2018 at 2:49 PM, Raul Miller wrote: > I remember at one point wishing that these would all work on character > and boxed data. > > Thanks, > > -- > Raul > > > On Fri, Apr 13, 2018 at 4:25 PM, Roger

Re: [Jprogramming] converting numbers and rank trouble

2018-04-13 Thread Raul Miller
I remember at one point wishing that these would all work on character and boxed data. Thanks, -- Raul On Fri, Apr 13, 2018 at 4:25 PM, Roger Hui wrote: > It's useful to have at your fingertips a (small) set of manoeuvers: > > x * 0 = 0 > x * 1 = x > > x ^ 0 = 1 >

Re: [Jprogramming] converting numbers and rank trouble

2018-04-13 Thread Roger Hui
It's useful to have at your fingertips a (small) set of manoeuvers: x * 0 = 0 x * 1 = x x ^ 0 = 1 x ^ 1 = x etc. The Y {~ X i. x phrase, for mapping cells in X to values in Y, is also generally useful. See the Dyalog APL blog post Calcultion v Look-Up

Re: [Jprogramming] converting numbers and rank trouble

2018-04-13 Thread Raul Miller
I had trouble myself understanding what Joe was driving at, and that lead to my mistaken call for better sample data. What Joe is working with is a character matrix - one row of characters represents one number. So there will be multiple columns in the source data and that corresponds to a list

Re: [Jprogramming] converting numbers and rank trouble

2018-04-13 Thread Don Guinn
Roger said that the boxed sample was only for illustration. But then, where does the empty box come from? Or is this a comma or tab delimited file? Granted, if the original file is pretty trashy then it is probably necessary to do some clean-up ending out in table of boxes. But if the data is

Re: [Jprogramming] converting numbers and rank trouble

2018-04-13 Thread Joe Bogner
Don - the source data is a text file of float data that is being read into J Roger - thanks, for the confirmation. I find that when I'm way from J/APL for awhile, my mind drifts back into "if/then" thinking instead of the simpler and faster method of using multiplication where possible. I fiddled

Re: [Jprogramming] converting numbers and rank trouble

2018-04-13 Thread Roger Hui
Yes, it's a boon that 0 * x is 0 for any x. Some authors go even further: Knuth propose to have 0 * x be 0 even when x is an expression which is in error. He wanted this to make "Iverson's convention" work in more situations. See https://arxiv.org/PS_cache/math/pdf/9205/9205211v1.pdf On Fri,

Re: [Jprogramming] converting numbers and rank trouble

2018-04-13 Thread Roger Hui
He's using boxed arrays only to generate the small sample data. On Fri, Apr 13, 2018 at 12:43 PM, Don Guinn wrote: > Just out of curiosity, surely the data didn't start out as an array of > boxes. Perhaps it might be faster not to have everything boxed. Validation > could

Re: [Jprogramming] converting numbers and rank trouble

2018-04-13 Thread Roger Hui
There is no faster way, although you can speed up "isblank": [: -. {.@(0&{.) -:"1 ] It's wasteful to catenate ' ' to a great big array only to take and drop its first cell. On Fri, Apr 13, 2018 at 12:24 PM, Joe Bogner wrote: > Well, I stumbled upon a fast way that

Re: [Jprogramming] converting numbers and rank trouble

2018-04-13 Thread Joe Bogner
Well, I stumbled upon a fast way that takes advantage of simple multiplication _ * 0 = 0 _ * 1 = _ 5 * 1 = 5 _3 {. (-.@isblank * _&".) c1 1.01 _ 0 (6!:2) '(isblank * _&".) c1' 1.00593 I'm still interested in alternatives that are similar speed if possible On Fri, Apr 13, 2018 at

Re: [Jprogramming] converting numbers and rank trouble

2018-04-13 Thread Joe Bogner
Thank you -- Yes, I didn't want to send along the full sample, although I could have created some dummy data. Both Don and Raul's method are similar and are equally slow as the way I had It's not terribly important but I have like 10 numeric columns that I convert in a script and have to

Re: [Jprogramming] converting numbers and rank trouble

2018-04-13 Thread Don Guinn
Is this what you want? _".&>'';'bad';'10' 0 _ 10 On Fri, Apr 13, 2018 at 12:03 PM, Joe Bogner wrote: > I have a large byte array that I want to convert to a number array. I want > to use _ to indicate a bad value, but blank should be treated as 0 > > $ c > 4862343 10