4. Half the Battle
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. For example, APL uses the function ÷ (Divide) for division.
An APL function takes the result of all the code to its right as its right argument. So 12÷3-1 gives 6, rather than the 3 that you might expect. This is because the ÷ takes the answer of 3-1 as its right argument.
You can use round brackets ( (…) ) to change the order in which things are calculated. When used, the right argument only goes as far as the nearest closing bracket on its right:
12÷3-1gives6because÷takes the result of all code to its right,3-1, as its right argument.12÷(3-1)gives6because÷takes the result of all code to its right,(3-1), as its right argument.(12÷3)-1gives3because the right argument of÷only goes as far as the nearest closing bracket.
Write an expression that gives calculates the difference between 9 and 4 and then divides that by 2. The result should be 2.5.