[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: Juergen Sauermann
Subject: Re: [Bug-apl] Performance problem with simple program
Date: Wed, 07 Oct 2015 13:27:19 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

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.

That does not sound that slow. In the 70s and 80's APL programmers were aware that
⍎ was inherently slow (due to the many things happening under the hood) and
did their best to avoid it.

These days I see more and more examples on the web where ⍎ is used, and
often without a real need to do so. Often APL programs look slighly more elegant
when ⍎ is used, but the speed penalty for doing so is considerable (and un-avoidable).
For the sake of APL I would hope that such examples will disappear.

/// Jürgen

On 10/06/2015 07:32 AM, Elias Mårtenson wrote:
I found the following quiz on G+, and decided to solve it with APL:


The solution I came up with was this:


This creates a table showing the number of pages, and the sum of the digits for that number of pages.

I was surprised that the program ran so slowly, taking almost a second to finish on my (pretty fast) computer.

I'll follow up with profiler results, but I was wondering of anyone can come up with a faster solution?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]