Skip to content

Read exercises

For each of the following exercises, try to figure out what the input will produce in the TryAPL terminal. Check your answers by opening the "Output" tab.

If you think an error will occur, try to predict which error it will be and where the arrow will point to.

The exercises are not checked or graded: use them to check your knowledge!

Number manipulation

Read problem 1

2 + 3
5

Read problem 2

2-3
¯1

The negative sign (¯) is different from the minus function (-)


Read problem 3

3*3
27

* is used for exponentiation, not multiplication


Read problem 4

3×3
9

Read problem 5

3÷2
1.5

Read problem 6

2¯7
SYNTAX ERROR
       7
      

The negative sign (¯) is not a function. Use the - function instead.


Read problem 7

1+2÷
SYNTAX ERROR
      1+2÷
         

The divide function is missing its right argument.


Read problem 8

100÷0
DOMAIN ERROR: Divide by zero
      100÷0
         

Can't divide by zero!


Read problem 9

0÷100
0

Read problem 10

0÷0
1

Ah, the age-old dilemma! Were you expecting a DOMAIN ERROR? The APL developers decided to add this feature since it is useful in some contexts. There is the option to change this if it really upsets you.


Read problem 11

¯2ׯ3
6

Order of execution

Read problem 12

4×2+3
20

Right-to-left.


Read problem 13

5×2   +   3×2
40

Still right-to-left, regardless of spaces.


Read problem 14

24÷8÷2
6

Read problem 15

3÷12 + 4ׯ3
DOMAIN ERROR: Divide by zero
      3÷12+4ׯ3
       

The 12 + ¯12 results in zero, which is outside of the domain of the divide function's right argument.


Read problem 16

(((2+3)))
5

Extra parentheses never hurt anyone.


Read problem 17

(((5))+((((3)))×(2)))
11

Very readable! Is this LISP?


Read problem 18

4×24÷3
32

Read problem 19

24÷4×3
2

Read problem 20

6×3-
SYNTAX ERROR
      6×3-
         

Typo.