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 […]
2019 APL Problem Solving Competition: Phase I Problems Sample Solutions
The following are my attempts at the Phase I problems of the 2019 APL Problem Solving Competition. There are not necessarily “right answers” as personal style and taste come into play. More explanation of the code is provided here than common practice. All solutions pass all the tests specified in the official problem description. 1. […]
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 […]
Diane's Lasagne Problem
Making Lasagne Participants in the SA2 Performance Tuning workshop at the Dyalog ’18 User Meeting were encouraged to bring their own problems for the group to work on. Diane Hymas of ExxonMobil brought a good one. The one-liner computation is as follows: lasagne0 ← {groups {+⌿⍵}⌸ amts ×[⎕io] spices[inds;]} where n ← 8e5 spices ← […]
Progressive Index-Of
⎕io=0 is assumed throughout. A recent Forum post motivated investigations into the progressive index-of functions in the FinnAPL Idiom Library: pix ← {((⍴⍺)⍴⍋⍋⍺⍳⍺,⍵) ⍳ ((⍴⍵)⍴⍋⍋⍺⍳⍵,⍺)} ⍝ FinnAPL Idiom 1 pixa ← {((⍋⍺⍳⍺,⍵)⍳⍳⍴⍺) ⍳ ((⍋⍺⍳⍵,⍺)⍳⍳⍴⍵)} ⍝ FinnAPL Idiom 5 In this note, we: explain what is progressive index-of explain why the two functions work investigate the […]
2018 APL Problem Solving Competition: Phase I Problems Sample Solutions
The following are my attempts at the Phase I problems of the 2018 APL Problem Solving Competition. There are not necessarily “right answers” as personal style and taste come into play. More explanation of the code is provided here than common practice. All solutions pass all the tests specified in the official problem description. The […]
Is it Sorted?
Motivation I have been working on the Dyalog APL quicksort implementation. The following programming puzzle arose in the process of doing the QA for this work. ⍵ is a simple array. Write a function sorted, without using ⍋ or ⍒, such that sorted ⍵ is 1 if ⍵ is sorted in ascending order and 0 […]
Dyadic Grade
⎕io=0 is assumed throughout. The essay talks only about ⍋ but the same ideas apply to ⍒. Background ⍋ has the distinction of being the first (in 1980) APL primitive function defined on major cells: the result orders items of a vector, rows of a matrix, planes of a 3-d array, etc. In the ordering […]
Linear Interpolation
⎕io=0 assumed throughout; works in 1-origin with the obvious modifications. Introduction On Wednesday, a question arrived via Dyalog Support from an intern in Africa: If M is the matrix on the left, use linear interpolation to compute the result on the right. 1 20 1 20 4 80 2 40 6 82 3 60 4 […]
Permuting Internal Letters
Friday Afternoon It’s something of a custom in Dyalog to send a “fun” e-mail to the group on Friday afternoons. My gambit for this past Friday was: x ←’ according to research it doesn”t matter’ x,←’ what order the letters in a word are’ x,←’ the human mind can still read it’ x,←’ the only […]