Skip to content

4. Grand Gesture

Note: In this problem, you’re asked to enter an APL expression (some APL code), including arguments (data given to APL symbols). Your code will be tested by the APL Challenge system to check whether it gives the correct answer and uses the methods described below.

Symbols that are used to change data are called functions.

The product of a list of numbers is result of multiplying all the numbers in the list. APL uses the function × (Times) for multiplication. For example, the product of 3 1 4 1 5 is 3×1×4×1×5 which is 60.

In APL, we do not have to write the same function again and again between all of the numbers. Instead, we can use / (Slash); a function to the left of a / will be inserted between the numbers on the right of that /. For example, the above product can be found with ×/ 3 1 4 1 5.

All other basic functions of APL can be used with / in the same way.

Remember from problem 2 that a matrix (table of numbers) can be written by enclosing its content in [] with the numbers in each row separated by spaces and the rows separated by .

The product of a matrix is a list of the products of the rows. For example, ×/ [3 1 4 1 5 ⋄ 1 6 1 8 0] gives 60 0 because:

  1. ×/ 3 1 4 1 5 is 60
  2. ×/ 1 6 1 8 0 is 0

An APL function takes the result of all code to its right as its right argument (the data on the right of the symbol). For example, 2×3+4 gives 14 (rather than the 10 you might expect) because the × takes the result of 3+4 as its right argument.


Write an expression that uses + with / to add all the numbers in the matrix [1 2 ⋄ 3 4]. The result should be 10.