Towards Improvements to Stencil
Background The stencil operator ⌺ was introduced in Dyalog version 16.0 in 2017. Recently we received some feedback (OK, complaints) that (a) stencil does padding which is unwanted sometimes and needs to be removed from the result and (b) stencil is too slow when it is not supported by special code. First, stencil in cases […]
Ascending and Descending
Lexicographic Ordering Lexicographic ordering is what the APL primitives ⍋ and ⍒ provide: ⎕io←0 ⍝ ⎕io delenda est ⎕rl←7*5 ⍝ to get reproducible random results a←?11 3⍴3 a a ⌷⍨⊂ ⍋a 2 1 0 0 1 0 0 2 2 0 2 2 1 1 1 1 0 0 1 0 0 1 0 1 […]
Krypto
In the 2016 Year Game, the task was to generate the numbers 0 to 100 using APL primitives and the digits 2 0 1 6 in that order. For example, 20=16 ×2016 2⌊016 2+×016 … This “puzzle of the year” brings to mind Krypto, a game I played many years ago while in grade school. […]
Beauty and the Beast
Finally, the last accessory I ordered for my Raspberry Pi Zero (that’s the little red thing behind my keyboard) has arrived – an Acer 43″ ET430K monitor. The Zero won’t quite drive this monitor at its maximum resolution of 3840×2160 pixels, but as you can see, you get enough real estate to do real graphics […]
Charting Reaction Times on the Raspberry Pi
Earlier this week I collected some reaction timer data on my Pi using the BBC micro:bit as an input device. I only produced an “ASCII art” chart at the time: times←ReactionTimer.Play times 251 305 294 415 338 298 294 251 378 ReactionTimer.AsciiChart times 425| 400| * 375| * 350+ 325| * 300| […]
APL Exercises
These exercises are designed to introduce APL to a high school senior adept in mathematics. The entire set of APL Exercises has the following sections: Introduction 0. Beginnings 1. Utilities 2. Recursion 3. Proofs 4. Rank Operator 5. Index-Of 6. Key Operator 7. Indexing 8. Grade and Sort 9. Power Operator 10. Arithmetic 11. Combinatorial […]
50847534
⎕io←0 throughout. I was re-reading A Mathematician’s Apology before recommending it to Suki Tekverk, our summer intern, and came across a statement that the number of primes less than 1e9 is 50847478 (§14, page 23). The function pco from the dfns workspace does computations on primes; ¯1 pco n is the number of primes less […]
Shuffle Faster Please!
Andy reported that in the shuffle QA some functions take a long time: m9249 “4½ days so far” rankop 21.5 hours m12466 26.3 hours points 7.2 hours Background: Shuffle QA is an intensification of the normal QA. The suite of over 1800 QA functions is run under shuffle, whereby every getspace (memory allocation) is followed by every APL array […]
The Halting Problem Rendered in APL
The halting problem is the problem of determining, from a description of a program and an input, whether the program will finish running or continue to run forever. It was proved in the negative by Alonzo Church and Alan Turing in 1936, and can be rendered in Dyalog APL as follows: Suppose there is an […]
Quicksort in APL Revisited
A message in the Forum inquired on sorting strings in APL with a custom comparison function. First, sorting strings without a custom comparison function obtains with a terse expression: {⍵[⍋↑⍵]} ‘syzygy’ ‘boustrophedon’ ‘kakistocracy’ ‘chthonic’ ┌─────────────┬────────┬────────────┬──────┐ │boustrophedon│chthonic│kakistocracy│syzygy│ └─────────────┴────────┴────────────┴──────┘ Sorting strings with a custom comparison function can also be accomplished succinctly by simple modifications to the Quicksort […]