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!

Read problem 1

      1 4 9 16 25[4]
      1 4 9 16 25[4]
16

Read problem 2

1 4 9 16 25[3 4 5]
      1 4 9 16 25[3 4 5]
9 16 25

Read problem 3

      (2×1 4 9 16 25)[4]

      (2×1 4 9 16 25)[4]
32
Remember, creating a vector takes precedence over any other operations.


Read problem 4

      (2×1) 4 9 16 25[4]
      (2×1) 4 9 16 25[4]
16

Read problem 5

      ¯1 4 9 16 25[2]
      ¯1 4 9 16 25[2]
4

Read problem 6

      -1 4 9 16 25[2]

      -1 4 9 16 25[2]
¯4
- is a function, which is applied to the whole vector, ¯ is the correct way to write negative numbers


Read problem 7

      1 2 3 4 ÷ 2 3 4 5
      1 2 3 4 ÷ 2 3 4 5
0.5 0.6666666667 0.75 0.8

Read problem 8

      1 2 ÷ 2 3 4 5
      1 2 ÷ 2 3 4 5
LENGTH ERROR: Mismatched left and right argument shapes
1 2÷3 4 5
   

Read problem 9

      5 5  0
      5 5  0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

Read problem 10

      5 5  ⎕A
      5 5  ⎕A
ABCDE
FGHIJ
KLMNO
PQRST
UVWXY

Read problem 11

      (5 5  ⎕A)[2 3 4;2 3 4]
      (5 5  ⎕A)[2 3 4;2 3 4]
GHI
LMN
QRS

Read problem 12

      10 11  '╚╗░'
      10 11  '╚╗░'
╚╗░╚╗░╚╗░╚╗
░╚╗░╚╗░╚╗░╚
╗░╚╗░╚╗░╚╗░
╚╗░╚╗░╚╗░╚╗
░╚╗░╚╗░╚╗░╚
╗░╚╗░╚╗░╚╗░
╚╗░╚╗░╚╗░╚╗
░╚╗░╚╗░╚╗░╚
╗░╚╗░╚╗░╚╗░
╚╗░╚╗░╚╗░╚╗