Solving the 2014 APL Problem Solving Competition – Cryptography Problem 1
This post is a continuation of the series where we examine some of the problems selected for the 2014 APL Problem Solving Competition. I’ll start by looking at the cryptography problems from Phase II. Cryptography Problem 1 – Vigenère Cipher The cipher is described using a large table of letters, but you don’t need to […]
The Diamond Kata
Acknowledgments Morten Kromberg is the other co-author of this text but the blogging software prevents his being listed as such. We are indebted to Jay Foad, Nick Nikolov, John Scholes, and Fiona Smith for comments on successive drafts of the MS. The Problem The diamond kata is a programming exercise used in the agile development, […]
Cholesky Decomposition
Morten was visiting Dyalog clients and forwarded a request: Can we have the Cholesky decomposition? If A is a Hermitian, positive-definite matrix, its Cholesky decomposition [0] is a lower-triangular matrix L such that A ≡ L +.× +⍉L. The matrix L is a sort of “square root” of the matrix A. For example: ⎕io←0 ⋄ […]
Three-and-a-bit
The most obvious expression for computing π in APL is ○1. But what if you can’t remember how ○ works, or your O key is broken, or you feel like taking the road less travelled? With thanks to Wikipedia’s excellent list of Approximations of π, here are some short sweet APL expressions for three-and-a-bit: 3 ⍝ very short […]
Quicksort in APL
Quicksort is a classic sorting algorithm invented by C.A.R. Hoare in 1961 [0, 1]. It has been known for some time that quicksort has a terse rendition in APL [2]. To get right to it, here is the code: Q←{1≥≢⍵:⍵ ⋄ S←{⍺⌿⍨⍺ ⍺⍺ ⍵} ⋄ ⍵((∇<S)⍪=S⍪(∇>S))⍵⌷⍨?≢⍵} The “pivot” ⍵⌷⍨?≢⍵ is randomly chosen. ((∇<S)⍪=S⍪(∇>S)) is a […]
Ken Iverson's Favourite APL Expression?
What was Ken Iverson’s favourite APL expression? I don’t know that he had one and if he had I don’t know what it was, but if I have to guess … From Sixteen APL Amuse-Bouches: The expression (0,x)+(x,0) or its commute, which generates the next set of binomial coefficients, is present in the document that […]
Musings on Reduction
In one man’s humble opinion, reduction (⌿) is the Queen of Operators. Each (¨) comes a close second, but doesn’t get the cigar because each can be written in terms of reduction. Two special cases are of interest: reduction along axes of length 1 (or reduction of a scalar) and reduction along axes of length […]
Solving the 2014 APL Problem Solving Competition – it's as easy as 1 1 2 3…
The winners of the 2014 APL Problem Solving Competition were recognized at the Dyalog ’14 user meeting and had a chance to share their competition experiences. Emil Bremer Orloff won the student competition and received $2500 USD and an expenses-paid trip to Dyalog ’14, while Iryna Pashenkovska took first place among the non-student entries and received a complimentary […]
A Speed-Up Story
The first e-mail of the work week came from Nicolas Delcros. He wondered whether anything clever can be done with ∘.≡ on enclosed character strings. I immediately thought of using “magic functions“, an implementation technique whereby interpreter facilities are coded as dfns. I thought of magic functions because the APL expressions involved in this case […]
Selective Expression Tracing
Operator trace from dfns.dws is a simple and low-tech tool for displaying intermediate results of functions, during the evaluation of an expression. For example, what’s going on here? (+⌿ ÷ ≢) 1 2 3 4 2.5 We can guess that the above fork is computing the average of the right argument. To see how this works: )copy dfns […]