Topic: APLX Help : Help on APL language : APL Primitives : - Subtract
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

- Subtract


Two-argument form  See also one-argument form Negate

Subtracts the number(s) in the right-hand argument from the number(s) in the left-hand argument:

              240-1                  (Subtracts one number from another)
       239
              8 4 6-1 0 2            (Subtracts each number in a vector from
       7 4 4                          the corresponding number in a vector of
                                      equal size)
             22 ¯4 15-1              (Subtracts 1 from each number in a
       21 ¯5 14                       vector of numbers)
             TABLE ← 3 3 ⍴ ⍳ 9
             100-TABLE               (Subtracts each number in a matrix
       99 98 97                       from a scalar)
       96 95 94
       93 92 91
             TABLE-TABLE             (Subtracts each number in a matrix
       0 0 0                          from the corresponding number in a
       0 0 0                          matrix of equal size and dimensions)
       0 0 0
             1 - 5 (2 2 ⍴⍳4) (⍳5)    (Each element in the right argument is
        ¯4     0 ¯1   0 ¯1 ¯2 ¯3 ¯4   subtracted from 1)
              ¯2 ¯3
             2  3-5 (2 2 ⍴⍳4) (⍳5)   (Arguments must be the same length)
       LENGTH ERROR
             2 3-5(2 2⍴⍳4)(⍳5)
             ^
             (2 2⍴⍳4) 10 (5⍴3)-5 (2 2 ⍴⍳4) (⍳5)
         ¯4 ¯3    9 8   2 1 0 ¯1 ¯2  (Corresponding elements subtracted)
         ¯2 ¯1    7 6

Note: Remember that APL uses a special symbol (the high minus ¯) to indicate negative numbers. You will see some examples above.


Topic: APLX Help : Help on APL language : APL Primitives : - Subtract
[ Previous | Next | Contents | Index | APL Home ]