Re: [Jprogramming] divide if not zero

2016-05-06 Thread Henry Rich
No, the line has to look exactly like what I showed, with nothing else added to the sentence. No assignments, no parentheses, no other verbs. Henry Rich On 5/6/2016 8:13 PM, Louis de Forcrand wrote: I see. So here the special code is implemented? 1e2 timespacex 'a=: c}a,:d=: a%b [ c=:

Re: [Jprogramming] divide if not zero

2016-05-06 Thread Louis de Forcrand
I see. So here the special code is implemented? 1e2 timespacex 'a=: c}a,:d=: a%b [ c=: 0 ~: b=: ?1e6#5 [ a=: ?1e6#5' 0.103524 6.71141e7 If I take the random generators out of the timer, then it is slightly faster and less space-hungry than the my previous expression: a=: ?1e6#5 b=: ?1e6

Re: [Jprogramming] Project Euler 1

2016-05-06 Thread Louis de Forcrand
(Unicode APL chars in this message! and a spoiler if you haven't yet found the solution!) I love showing off the APL (from the original book) solution for this to people who have heard nothing of array-based languages: V +.× ∊ ∨.= N ∘.| V which finds the sum of the numbers in the vector V whi

Re: [Jprogramming] divide if not zero

2016-05-06 Thread Henry Rich
See http://code.jsoftware.com/wiki/Vocabulary/SpecialCombinations#Assignments_In_Place_.28AIP.29 a=: (b~:0)}a,:a%b is not in-place because it doesn't match the template. In fact, it isn't handled by special code at all, see http://code.jsoftware.com/wiki/Vocabulary/SpecialCombinations#Select

Re: [Jprogramming] divide if not zero

2016-05-06 Thread Louis de Forcrand
(0 = {:)`(%/ ,: {.)}@,: is another solution. It has the same effect as ([ * 0 = ]) + % * 0 ~: ] or %^:(~:&0)"0 in that it keeps the original number instead of replacing it by 0. As a side-note, I was surprised not to find special code associated with v1`v2}, especially if v2 has the form u ,: v. An

Re: [Jprogramming] Project Euler 1

2016-05-06 Thread 'Pascal Jasmin' via Programming
"0 1 vs / is just fine. I recommend thinking in a fork only model for starting tacit code because a single model all powerful model is easier to apply, and other forms (hook, &) are mere shortcuts. similarly, "0 1 (or I think more accurately "_1 _) is a good way to understand rank better. Als

Re: [Jprogramming] Project Euler 1

2016-05-06 Thread David Lambert
Somewhere in the essay archives http://code.jsoftware.com/wiki/Essays it is written that (as I recall) Ken & Roger, upon realizing that rank could do the work of table as you have discovered, were disappointed to wasted a good symbol on table. Date: Fri, 6 May 2016 12:03:15 -0400 From: Geoff

Re: [Jprogramming] Project Euler 1

2016-05-06 Thread Geoff Canyon
On Fri, May 6, 2016 at 4:43 AM, Martin Kreuzer wrote: > At that stage I realized that (/) isn't only "Insert" but also used to > force a "Table": > ​Yep, this was new to me as well, as evidenced by my original awkward |"0 1 construction. --

Re: [Jprogramming] Project Euler 1

2016-05-06 Thread Raul Miller
A1: This does what I think you want: (,2) (0 +./ .= (|/ i.)) 10 1 0 1 0 1 0 1 0 1 0 I think it's reasonable to expect that the left argument always be a list (aka "a vector"). But, if you like, you could wrap this in code that guarantees vectorness. Since the rank of the right argument doesn'

Re: [Jprogramming] divide if not zero

2016-05-06 Thread 'Bo Jacoby' via Programming
x%y+y=0 Den 3:37 fredag den 6. maj 2016 skrev Joe Bogner : > > On 6 May 2016, at 10:53 AM, 'Pascal Jasmin' via Programming < > programm...@jsoftware.com> wrote: > > > > I would go with first version.  What don't you like about it? Thanks - I don't particularly like using explicit rank

Re: [Jprogramming] Project Euler 1

2016-05-06 Thread Martin Kreuzer
In the effort of generalizing it more, I noticed that (3 5) (0 +./ .= (|/ i.)) 10 1 0 0 1 0 1 1 0 0 1 works fine, but collapses when only on divider is given (2) (0 +./ .= (|/ i.)) 10 1 (looks like the resulting vector being ORed). Q1: Is there a possible twist to bring these two cases

Re: [Jprogramming] Project Euler 1

2016-05-06 Thread Martin Kreuzer
Let me add that, following this thread so far, I too learned a few things today - and pardon me for outlining the steps for further reference. I (again) did a very base level approach: 3 + 8 9 10 11 12 13 5 + 8 9 10 13 14 15 3 5 + 8 9 10 |length error | 3 5+8 9 10 At that stage