Re: [Bug-apl] Performance problem with simple program

2015-10-12 Thread Juergen Sauermann
Hi Alex, yes, correct. /// Jürgen On 10/12/2015 05:37 AM, alexwei...@alexweiner.com wrote: Jürgen, Just wondering: Does this optimization in SVN 682 also apply to

Re: [Bug-apl] Performance problem with simple program

2015-10-11 Thread Elias Mårtenson
I was just looking at the change, and it's the addition of the following code, run just after the check for ) or ] commands: Token constant; ExecuteList * fun = ExecuteList::fix(statement.no_pad(), constant, LOC); if (fun == 0) { if (constant.get_tag() == TOK_APL_VALUE1) return

Re: [Bug-apl] Performance problem with simple program

2015-10-11 Thread alexweiner
Jürgen,Just wondering: Does this optimization in SVN 682 also apply to a homogeneous list of numbers? For example, if the input string is '1 2 3 3 45 3 2'. Is this what you mean when using the term 'single value' ?-Alex

Re: [Bug-apl] Performance problem with simple program

2015-10-11 Thread Juergen Sauermann
Hi Elias, I have added an optimization for ⍎ with a single APL value. SVN 682. /// Jürgen On 10/09/2015 04:36 PM, Elias Mårtenson wrote: Hello Jürgen, I am assuming that I am not alone

Re: [Bug-apl] Performance problem with simple program

2015-10-10 Thread Juergen Sauermann
Hi Elias, good idea, I will look into this. Do you have your code somewhere? I believe the proper way is to stop after the tokenizer stage if the result is a single APL value. That way no extra processing is performed and parsing and creation

Re: [Bug-apl] Performance problem with simple program

2015-10-10 Thread Blake McBride
I think this is a great optimization!! On Fri, Oct 9, 2015 at 9:36 AM, Elias Mårtenson wrote: > Hello Jürgen, > > I am assuming that I am not alone in commonly using ⍎ for the purpose of > parsing a number embedded in a string as APL (i.e. something analogous to > PARSE-INTEGER in Lisp, or strt

Re: [Bug-apl] Performance problem with simple program

2015-10-09 Thread Elias Mårtenson
Hello Jürgen, I am assuming that I am not alone in commonly using ⍎ for the purpose of parsing a number embedded in a string as APL (i.e. something analogous to PARSE-INTEGER in Lisp, or strtol() in C). With that in mind, I made a small change to Bif_F1_EXECUTE::execute_statement() which checked

Re: [Bug-apl] Performance problem with simple program

2015-10-07 Thread Peter Teeson
Of course this was in the context of Jay’s comment on Elias’ APL. So in that specific case Jay suggested: (⍳N)⍪[1.5]+\+⌿10 10 10⊤⍳N←400 and then modified it, suggesting ((1+⌊10⍟N)⍴10) to become (⍳N)⍪[1.5]+\+⌿((1+⌊10⍟N)⍴10)⊤⍳N←400 But this produces the same result: (⍳N)⍪[1.5]+\+⌿((⌈10⍟N)⍴10)⊤⍳N←400

Re: [Bug-apl] Performance problem with simple program

2015-10-07 Thread Juergen Sauermann
Hi Peter, I guess when L⍟(|R)+R=0 is integer then ⌈ and ⌊ would be the same and then the  1+⌊ is different from ⌈. /// Jürgen On 10/07/2015 04:19 PM, Peter Teeson wrote: Re: encode ((1+⌊10⍟N)⍴10)⊤...

Re: [Bug-apl] Performance problem with simple program

2015-10-07 Thread Jay Foad
On 7 October 2015 at 15:19, Peter Teeson wrote: > I was wondering why the APL Lang Ref Manual p.161 shows: > ⌊1+L⍟(|R)+R=0 > > Why would this not be just as correct? > ⌈L⍟(|R)+R=0 > > and so >> ((⌈10⍟N)⍴10)⊤... This would tell you that 1000 only has 3 digits. Jay.

Re: [Bug-apl] Performance problem with simple program

2015-10-07 Thread Peter Teeson
Re: encode > ((1+⌊10⍟N)⍴10)⊤... I was wondering why the APL Lang Ref Manual p.161 shows: ⌊1+L⍟(|R)+R=0 Why would this not be just as correct? ⌈L⍟(|R)+R=0 and so > ((⌈10⍟N)⍴10)⊤... two symbols less……..

Re: [Bug-apl] Performance problem with simple program

2015-10-07 Thread Juergen Sauermann
Hi Elias, using ⍎ in an inner loop is almost certainly a mistake. In your example ⍎ is evaluated 202287 times. That means we have less than 5 micro-seconds for tokenising, parsing, and executing the left argument of ⍎ and for producing it.

Re: [Bug-apl] Performance problem with simple program

2015-10-06 Thread Jay Foad
It's slightly annoying that you have to know how many 10s to use on the left of ⊤. You can work it out as: ((1+⌊10⍟N)⍴10)⊤... On 6 October 2015 at 09:44, Jay Foad wrote: > (⍳N)⍪[1.5]+\+⌿10 10 10⊤⍳N←400

Re: [Bug-apl] Performance problem with simple program

2015-10-06 Thread Jay Foad
Your solution is inherently O(n²) because you're using ¨⍳ inside ¨⍳. The obvious way to fix this is with +\: (⍳N)⍪[1.5]+\{+/⍎¨⍕⍵}¨⍳N←400 The other obvious source of inefficiency is your use of ⍕ and ⍎. Instead, how about: (⍳N)⍪[1.5]+\+⌿10 10 10⊤⍳N←400 I don't know how to do timings in GNU APL s

[Bug-apl] Performance problem with simple program

2015-10-05 Thread Elias Mårtenson
I found the following quiz on G+, and decided to solve it with APL: https://plus.google.com/108865431001865524379/posts/FKMrYkF6h3u The solution I came up with was this: * (⍳N)⍪[1.5]{+/⍎¨⊃,/⍕¨⍳⍵}¨⍳N←400* This creates a table showing the number of pages, and the sum of the digits for that n