Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
How about an extreme version of the sort problem. Suppose x is a vector of bits (such as they have in APL). How do you sort x? This would have been one way to solve the sorting small integers problem: figure out how to sort 0-1 vectors and then work your way up from that. I once posed the 88 Ha

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Linda Alvord
Reading about dyadic /: made me realize I didn't answer your challenge: B=:'I was sloppy before.' f=:/: g=:/: { ] h=:f;g h B ┌─┬┐ │1 5 12 19 0 3 13 14 18 15 7 8 16 9 10 17 4 6 2 11│ .Iabeefloopprsswy│ └

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
You use s=:/:~x to get the sort and g=:/:x to get the grade. It's faster than s=:x{~g=:/:x . (That's the bar bet.) Counter-intuitive to anyone who thinks indexing is always faster than sorting, or that sorting is necessarily an expensive slow operation. Knowing this is a strong hint on how to f

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Linda Alvord
But if you use dyadic /: you won't get g , will you? I'm looking forward to reading all the quotes again. Linda -Original Message- From: programming-boun...@forums.jsoftware.com [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Roger Hui Sent: Wednesday, March 05, 2014

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Raul Miller
Testing is something I find myself repeatedly struggling with also. I'm great at making mistakes, and inspecting results seems like the crucial difference between a plausible mistake and being actually productive. Thanks, -- Raul On Wed, Mar 5, 2014 at 10:55 PM, Roger Hui wrote: > Right. I

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
I respectfully suggest you study the dyad /: . The fact that the dyad /: is defined to do what it does is one of Ken Iverson's masterstrokes . On Wed, Mar 5, 2014 at 7:46 PM, Linda Alvord wrote: > For me slow J is fast enough, but I really was delighted when this

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Yike Lu
Joe, wonderful explanation. This was exactly what I was wondering! I was just so surprised that my dumb indexing was only as fast as the sort itself. Seemed very counterintuitive. I suspected the bounds check, but this seems more plausible. On Wed, Mar 5, 2014 at 9:28 PM, Joe Bogner wrote: > On

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
Right. I do need the break. That's what I get when I post code without testing it. On Wed, Mar 5, 2014 at 7:53 PM, Raul Miller wrote: > Won't it give the maximum though, instead of the minimum? > > Thanks, > > -- > Raul > > > > On Wed, Mar 5, 2014 at 8:43 PM, Roger Hui > wrote: > > > Yes,

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Raul Miller
Won't it give the maximum though, instead of the minimum? Thanks, -- Raul On Wed, Mar 5, 2014 at 8:43 PM, Roger Hui wrote: > Yes, a break or return would be nice. It's still OK without that, because > it's looping a maximum of M times. > > > > On Wed, Mar 5, 2014 at 5:00 PM, Raul Miller w

Re: [Jprogramming] Generating code from templates

2014-03-05 Thread Raul Miller
You might use -.&a: to clean a result before `:6 hits it? Thanks, -- Raul On Wed, Mar 5, 2014 at 9:24 PM, Pascal Jasmin wrote: > > > Looks nice. Here is a continuation of my gerund manipulation approach: > > conjoin=: (,@:[ <@:; <@:])"1 > > ('@' conjoin -.`*) `:6 > -.@* > > '@' conjoin

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Linda Alvord
For me slow J is fast enough, but I really was delighted when this worked at all. No doubt it is slow. ]A=:?10$100 63 92 51 92 39 15 43 89 36 69 f=:/: g=:/: { ] h=:f;g h A T-┐ │5 8 4 6 2 0 9 7 1 3│15 36 39 43 51 63 69 89 92 92│ L

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Joe Bogner
On Wed, Mar 5, 2014 at 5:19 PM, Roger Hui wrote: > Good answers. For /:~x vs. g{x, the explanations are: > >- Indexing must check for index error. Sorting does not. >- Indexing uses random read access over a large chunk of memory (i.e. >x). Sort does not. > I was curious how much o

Re: [Jprogramming] Generating code from templates

2014-03-05 Thread Pascal Jasmin
Looks nice.  Here is a continuation of my gerund manipulation approach: conjoin=: (,@:[ <@:; <@:])"1   ('@' conjoin -.`*) `:6 -.@*  '@' conjoin (-.`'') ," 1 ,. *`-`+ ┌──┬──┬──┐ │┌─┬──┐│┌─┬──┐│┌─┬──┐│ ││@│┌──┬─┐│││@│┌──┬─┐│││@│┌──┬─┐││ ││ ││-.│* ││-.│-││

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
It's necessary to have the g because I asked for both the sort (s) and the grade, which would be the g. The problem arose in an application where the sort and the grade are used for something else. On Wed, Mar 5, 2014 at 4:32 PM, Don Kelly wrote: > Why is it necessary to have 'g' > > repeatin

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
Yes, a break or return would be nice. It's still OK without that, because it's looping a maximum of M times. On Wed, Mar 5, 2014 at 5:00 PM, Raul Miller wrote: > You probably want a return or break statement in that second loop? > > Thanks, > > -- > Raul > > > > On Wed, Mar 5, 2014 at 7:13 PM

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Yike Lu
Roger, just realized you'd have to loop through and do comparisons to find the min and max anyways, so would be essentially same amount of operations as a bounds checked lookup. Silly me. -- For information about J forums see http:

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Raul Miller
You probably want a return or break statement in that second loop? Thanks, -- Raul On Wed, Mar 5, 2014 at 7:13 PM, Roger Hui wrote: > > it avoids any branching in the loop. And no "comparisons". > > I1 b[M]; > memset(b,0x00,sizeof(b)); > for(i=0;i for(i=0;i > Well, there is

Re: [Jprogramming] jhs javascript draw()

2014-03-05 Thread Raul Miller
semicolons are an optional line end indicator in javascript. Newlines and closing braces can also terminate a statement. Newlines are a slightly ambiguous line end indicator in javascript. In some cases javascript will allow a statement to be spread across multiple lines. Semicolons are useful to

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Don Kelly
Why is it necessary to have 'g' repeating the process on my machine which is obviously slower gives an insignifcant time difference. 20 timer 's=:/:~x [ /:x' 0.172937 20 timer 's=:/:~x [ g=:/:x' 0.173672 Is it because storage is necessary and it is just as fast to store to a named locat

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
> it avoids any branching in the loop. And no "comparisons". I1 b[M]; memset(b,0x00,sizeof(b)); for(i=0;i wrote: > Zehr gut. It's not just that it's O(n) (the conventional if(min>*x)min=*x > is also O(n)) but it avoids any branching in the loop. And no > "comparisons". > > Bonus qu

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
Zehr gut. It's not just that it's O(n) (the conventional if(min>*x)min=*x is also O(n)) but it avoids any branching in the loop. And no "comparisons". Bonus question: Suppose M is really large and the cost of setting count to 0 is prohibitive. How can you avoid that cost? (Not saying it's rel

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
And how do you find the max and min in the general case? On Wed, Mar 5, 2014 at 3:58 PM, Yike Lu wrote: > I suppose it'd be too expensive in the general case to check max, min > versus shape? > > > On Wed, Mar 5, 2014 at 5:27 PM, Peter B. Kessler < > peter.b.kess...@oracle.com > > wrote: > > >

Re: [Jprogramming] Generating code from templates

2014-03-05 Thread Jose Mario Quintana
Yes, the old forms (c0 a1) and (a0 c1 a2) are back, lev and dex are are not provided but they can defined easily as, lev=. [ conj dex=. ] conj * lev + * * dex + + See http://journalofj.com/index.php/vol-2-no-2-october-2013 for more details (only the definition of the new conjunction kn

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Yike Lu
I suppose it'd be too expensive in the general case to check max, min versus shape? On Wed, Mar 5, 2014 at 5:27 PM, Peter B. Kessler wrote: > For the minimum in a small universe, use your "broken" sorting code (:-) > > > I4 count[M]; > memset(count,0x00,sizeof(count)); > for(i=0;i >

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Peter B. Kessler
For the minimum in a small universe, use your "broken" sorting code (:-) I4 count[M]; memset(count,0x00,sizeof(count)); for(i=0;i Good answers. For /:~x vs. g{x, the explanations are: - Indexing must check for index error. Sorting does not. - Indexing uses random read acces

Re: [Jprogramming] logic

2014-03-05 Thread Michal Wallace
Heya Pascal: Yep, the binary representation of i.2^n gives you every combination of n bits (n boolean inputs). I'm not sure I understand what you mean by the state of propositions. Are you talking about being able to assert and retract facts and rules, like in prolog? I made a little datalog-li

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Thomas Costigliola
On Mar 5, 2014 6:09 PM, "Roger Hui" wrote: > > > It begs the question why the bounds check is inside the loop. > > Can't you check against shape? > > There is no alternative. In g{x where g is a vector and ** it doesn't know > that g is the grade of x **, it has to check every element of g for in

[Jprogramming] jhs javascript draw()

2014-03-05 Thread Brian Schott
In my turtle graphics app based on Eric's jdemogl1.ijs I want to use the drawPrimitive() function to draw a line. For now I am experimenting with drawing directly from ev_command_enter_ajax(ts). My version of ev_command_enter_ajax() is below, and when I leave all 3 lines of code in, I get the erro

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
> It begs the question why the bounds check is inside the loop. > Can't you check against shape? There is no alternative. In g{x where g is a vector and ** it doesn't know that g is the grade of x **, it has to check every element of g for index error. > I'm aware of branch mis predict costs. T

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Yike Lu
I'm aware of branch mis predict costs. It begs the question why the bounds check is inside the loop. Can't you check against shape? On Mar 5, 2014 4:57 PM, "Roger Hui" wrote: > Compare the two: > > Sorting (fixed typos!): > > I4 count[M]; > memset(count,0x00,sizeof(count)); > for(i=0;i for(i=0;i

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
Compare the two: Sorting (fixed typos!): I4 count[M]; memset(count,0x00,sizeof(count)); for(i=0;ihttps://en.wikipedia.org/wiki/Branch_predictor>. Apparently the rest of the world is catching up to APL/J. See also Knuth's Two Notes on Notation

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Yike Lu
Yeah, it's N log N only if the domain is truly infinite (arbitrary precision). Everything else you can use radix with O(N b) where b is number of bits. On Wed, Mar 5, 2014 at 4:41 PM, Yike Lu wrote: > Roger, why is index lookup so slow in the g2 case (see my message > earlier)? Are you really s

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Yike Lu
Roger, why is index lookup so slow in the g2 case (see my message earlier)? Are you really saying that bounds checking makes it so that the lookup is only as fast as the sort? On Wed, Mar 5, 2014 at 4:35 PM, Roger Hui wrote: > > I4 count[M]; > > memset(count,0x00,sizeof(count)); > > for(i=0;i >

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
> DO(p, DO(yv[j], *v++=j;); yv[j]=0; ++j;); I wonder why I set yv[j] to 0? I see it's there in the source but it shouldn't be necessary. On Wed, Mar 5, 2014 at 2:32 PM, Joe Bogner wrote: > Roger, thanks for the explanation. I was just getting to that point in > the C code. > > No wonder I co

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Thomas Costigliola
My lazy answer is: You can do some bit twiddling to remove the comparison. On Wed, Mar 5, 2014 at 5:26 PM, Roger Hui wrote: > > min=-32768; > > for(i=0;i*x)min=*x; ++x;} > > Typo: I mean min=32767;, of course. > > > > > On Wed, Mar 5, 2014 at 2:19 PM, Roger Hui > wrote: > > > Good answers.

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
> I4 count[M]; > memset(count,0x00,sizeof(count)); > for(i=0;i wrote: > Good answers. For /:~x vs. g{x, the explanations are: > >- Indexing must check for index error. Sorting does not. >- Indexing uses random read access over a large chunk of memory (i.e. >x). Sort does not. > > A

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Joe Bogner
Roger, thanks for the explanation. I was just getting to that point in the C code. No wonder I couldn't figure it out at first. I was expecting to see a sort algorithm. The C code is remarkably clear once the intent is known. I had to step through it to visualize what it was doing. Count up the o

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Thomas Costigliola
I twiddle my thumbs a bit while waiting for someone to post the code :-) On Wed, Mar 5, 2014 at 5:29 PM, Roger Hui wrote: > Please explain the technical term "twiddling". :-) > > > > On Wed, Mar 5, 2014 at 2:28 PM, Thomas Costigliola >wrote: > > > My lazy answer is: You can do some bit twiddli

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
Please explain the technical term "twiddling". :-) On Wed, Mar 5, 2014 at 2:28 PM, Thomas Costigliola wrote: > My lazy answer is: You can do some bit twiddling to remove the comparison. > > > On Wed, Mar 5, 2014 at 5:26 PM, Roger Hui > wrote: > > > > min=-32768; > > > for(i=0;i*x)min=*x; ++x

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
Doing in O(n) gets you in the door; reducing the coefficient gets you the big bucks. :-) On Wed, Mar 5, 2014 at 2:19 PM, Yike Lu wrote: > I changed the power of 10 by +/- 1, the timing changed by the same order of > magnitude on both "/:~x" and "g{x". The second result we expect, each > looku

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
> min=-32768; > for(i=0;i*x)min=*x; ++x;} Typo: I mean min=32767;, of course. On Wed, Mar 5, 2014 at 2:19 PM, Roger Hui wrote: > Good answers. For /:~x vs. g{x, the explanations are: > >- Indexing must check for index error. Sorting does not. >- Indexing uses random read access o

Re: [Jprogramming] Simple Number Theory

2014-03-05 Thread Bo Jacoby
That makes sense!. Thanks. Den 23:09 onsdag den 5. marts 2014 skrev Pascal Jasmin : I assume the main motivation for the feature is ^:(<_) > > >- Original Message - >From: Bo Jacoby >To: "programm...@jsoftware.com" >Cc: >Sent: Wednesday, March 5, 2014 4:43:14 PM >Subject: Re: [Jpr

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
Good answers. For /:~x vs. g{x, the explanations are: - Indexing must check for index error. Sorting does not. - Indexing uses random read access over a large chunk of memory (i.e. x). Sort does not. A more detailed explanation: To sort over a small known universe (and characters def

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Yike Lu
I changed the power of 10 by +/- 1, the timing changed by the same order of magnitude on both "/:~x" and "g{x". The second result we expect, each lookup is constant time, so the total operation is O(n). The sort implies that J defaults to bucket/radix sort under the covers for characters. Thus the

Re: [Jprogramming] Simple Number Theory

2014-03-05 Thread Pascal Jasmin
I assume the main motivation for the feature is ^:(<_) - Original Message - From: Bo Jacoby To: "programm...@jsoftware.com" Cc: Sent: Wednesday, March 5, 2014 4:43:14 PM Subject: Re: [Jprogramming] Simple Number Theory Interesting, Dan, but why define  ^:(<20) meaning ^:(i.<20)  ?   

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Henry Rich
I would think sorting characters would count the occurrences of each character and then return count # a. Henry Rich On 3/5/2014 4:58 PM, Thomas Costigliola wrote: Is /:~ on characters using a radix sort? Even so, both sort and from I would think is O(N). What is all the overhead in from? O

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Thomas Costigliola
Is /:~ on characters using a radix sort? Even so, both sort and from I would think is O(N). What is all the overhead in from? On Wed, Mar 5, 2014 at 4:45 PM, Raul Miller wrote: > The rascal! > > -- > Raul > > > On Wed, Mar 5, 2014 at 4:38 PM, Joe Bogner wrote: > > > hey hey - I posted my first

Re: [Jprogramming] Simple Number Theory

2014-03-05 Thread Raul Miller
i.<20 is a domain error -- Raul On Wed, Mar 5, 2014 at 4:43 PM, Bo Jacoby wrote: > Interesting, Dan, but why define ^:(<20) meaning ^:(i.<20) ? > >(-:&(+ (2&| * >:&+:)))^:(<20)11 > 11 17 26 13 20 10 5 8 4 2 1 2 1 2 1 2 1 2 1 2 >(-:&(+ (2&| * >:&+:)))^:(i.20)11 > 11 17 26 13 20 10 5

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Raul Miller
The rascal! -- Raul On Wed, Mar 5, 2014 at 4:38 PM, Joe Bogner wrote: > hey hey - I posted my first answer before looking at the source and it > didn't change my answer. Also, Roger has the source in his head and it > wasn't ruled out of bounds. > > On Wed, Mar 5, 2014 at 4:35 PM, Raul Miller

Re: [Jprogramming] Simple Number Theory

2014-03-05 Thread Bo Jacoby
Interesting, Dan, but why define  ^:(<20) meaning ^:(i.<20)  ?    (-:&(+ (2&| * >:&+:)))^:(<20)11 11 17 26 13 20 10 5 8 4 2 1 2 1 2 1 2 1 2 1 2    (-:&(+ (2&| * >:&+:)))^:(i.20)11 11 17 26 13 20 10 5 8 4 2 1 2 1 2 1 2 1 2 1 2 - Bo Den 16:35 onsdag den 5. marts 2014 skrev Raul Miller : And wi

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Joe Bogner
hey hey - I posted my first answer before looking at the source and it didn't change my answer. Also, Roger has the source in his head and it wasn't ruled out of bounds. On Wed, Mar 5, 2014 at 4:35 PM, Raul Miller wrote: > My guess would be that it has something to do with cache coherence. > > In

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Raul Miller
My guess would be that it has something to do with cache coherence. Indexing is random access, sorting is more sequential in nature. But that's just a guess, because I did not cheat and look at the source or anything (at least... not today). Thanks, -- Raul On Wed, Mar 5, 2014 at 2:45 PM, R

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
It doesn't count. :-) On Wed, Mar 5, 2014 at 12:33 PM, Pascal Jasmin wrote: > I don't know if this counts, but the 2nd is 20% faster than Joe's > alternate (x at 1e6 not 1e7) > >ts' (/:~ [ /:) x' > 110.779/sec 9.43923MB >ts' (/:~ ; /:) x' > 77.8271/sec 9.43962MB > > > > - Original M

Re: [Jprogramming] Generating code from templates

2014-03-05 Thread Brian Schott
Will these train extensions reenable some of the trains involving adverbs and conjunctions, that were de-committed in J several years ago? Or will the newer such trains behave differently from or independently of those gone? (And what about the conjunctions dex and lev?) -- (B=)

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Pascal Jasmin
I don't know if this counts, but the 2nd is 20% faster than Joe's alternate (x at 1e6 not 1e7)    ts' (/:~ [ /:) x' 110.779/sec 9.43923MB    ts' (/:~ ; /:) x' 77.8271/sec 9.43962MB - Original Message - From: Joe Bogner To: programm...@jsoftware.com Cc: Sent: Wednesday, March 5, 2014

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
That's cheatin', looking at the source! :-) Further comments later. On Wed, Mar 5, 2014 at 12:11 PM, Joe Bogner wrote: > Yes, the grade is done regardless. Here's my reasoning: In the > incumbent version, s is taken from the grade with from { which is > slower than just resorting. > It seem

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Joe Bogner
Yes, the grade is done regardless. Here's my reasoning: In the incumbent version, s is taken from the grade with from { which is slower than just resorting. It seems like the difference between sorting and selecting by indexes. I am surprised if that's the answer though because selecting by index s

Re: [Jprogramming] Tacit recursion without $:

2014-03-05 Thread Pascal Jasmin
I think these are all valuable extensions, the one that is hardest to see the benefit of at first is  (a v) y => (v y) a y another example than L:v not being implemented is (n :) v , and so custom definition processing such as  http://www.jsoftware.com/jwiki/action/userprefs/PascalJasmin/Multi

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
x=: a.{~ 1e7 ?@$ 256 timer=: 6!:2 10 timer 's=:x{~g=:/:x' 0.136961 10 timer 's=:/:~x [ g=:/:x' 0.0765459 10 timer '/:~x' 0.012887 10 timer 'x{~g' 0.065751 10 timer '/:x' 0.0606987 On Wed, Mar 5, 2014 at 11:45 AM, Roger Hui wrote: > That's my alternative faster expression

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
That's my alternative faster expression as well. But the more interesting question is, why is it faster? Since we do the grade in both cases, the comparison is between /:~x and g{x (or x{~g) with g pre-computed. The answer does not depend knowledge specific to J. On Wed, Mar 5, 2014 at 11:3

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Joe Bogner
Sorting and grading separately seems faster timer=: 6!:2 x=:(1e7 $ 26?26) { 'abcdefghijklmnopqrstuvwxyz' NB. incumbent timer 's=: x{~g=: /:x' 0.0914002 NB. alternate timer 'S=: /:~x[G=: /:x' 0.0668677 s-:S 1 G-:g 1 I am speculating that sorting does it in place? which is faster than the se

Re: [Jprogramming] Generating code from templates

2014-03-05 Thread Jose Mario Quintana
Pascal wrote: >the above is not a useless pattern, but it would still be nice to have a real short circuit. >the pattern: doN^:testN...@:do2^:test2@:do1^:test1 >might be implementable using clever `:3, and ^:`@: but its not >straightforawd to This is one way (using verbalized adverbs and conj

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Raul Miller
Hmm... G=:a.i.S=:/:~x is faster. But while s-:S, g and G are different. So I'm drawing a blank here, on how to make the grade. Thanks, -- Raul On Wed, Mar 5, 2014 at 1:52 PM, Roger Hui wrote: > Suppose x is a long vector of characters and you need both its sort and its > grade. Can you

[Jprogramming] a good bar bet!

2014-03-05 Thread Roger Hui
Suppose x is a long vector of characters and you need both its sort and its grade. Can you do it faster than s=: x{~g=: /:x ? Posed this way, the answer is of course yes. But how, and why is it faster? -- For information about J

Re: [Jprogramming] Tacit recursion without $:

2014-03-05 Thread Jose Mario Quintana
I had not realized that the following replies to Linda and Don were skipped because of the 100 KB limit: _ From: Jose Mario Quintana Date: Sun, Feb 23, 2014 at 9:12 PM Subject: Re: [Jprogramming] Tacit r

Re: [Jprogramming] Simple Number Theory

2014-03-05 Thread Raul Miller
And with ^:(-i.|integer) where 0 >: integer Of course, if you want more control you'll need to be more explicit: >:^:(i:4) 5 6 7 1 2 3 2 3 4 3 4 5 4 5 6 5 6 7 6 7 8 7 8 9 8 9 10 9 10 11 Also, >:^:(n) y is n+/y with n constrained to integers. Thanks, -- Raul On Wed, Mar 5,

Re: [Jprogramming] Remove 1s from shapes

2014-03-05 Thread Roger Hui
My guess is that this sort of thing is too rare to justify special code. name =: (some noun) name =: (new shape) ($,) name On Wed, Mar 5, 2014 at 5:43 AM, Dan Bron wrote: > Roger wrote: > > x($,)y does make a copy of the values of y > > True, though I'd say this is implied in every st

Re: [Jprogramming] Simple Number Theory

2014-03-05 Thread Dan Bron
FYI, ^:( Date: Tue, 04 Mar 2014 21:46:16 -0500 To: |. f ^:(i.80)2324 2 1 2 4 8 5 10 20 40 80 53 35 23 46 92 61 122 244 488 325 Linda -Original Message- From: programming-boun...@forums.jsoftware.com [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Linda Alv

Re: [Jprogramming] DLL with dynamic classes and namespaces

2014-03-05 Thread bill lam
Those extern c functions can call other c++ functions. On Mar 5, 2014 9:53 PM, "Jan Jacobs" wrote: > ls, > to interface with a certain (C++) DLL I have a need to call the constructor > of a certain class within a namespace before I execute followup methods > within that particular class instance.

[Jprogramming] DLL with dynamic classes and namespaces

2014-03-05 Thread Jan Jacobs
ls, to interface with a certain (C++) DLL I have a need to call the constructor of a certain class within a namespace before I execute followup methods within that particular class instance. I experimented with 'extern "C"' designations but they seem to work only for static, classless, and non-name

Re: [Jprogramming] Remove 1s from shapes

2014-03-05 Thread Dan Bron
Roger wrote: > x($,)y does make a copy of the values of y True, though I'd say this is implied in every statement about performance in J, or special code that speeds it up (with a few specific, documented, and well-known exceptions). Hmm, maybe it's worth making a new exception? name =: (som