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

www.microapl.co.uk

| Residue


Two-argument form  See also one-argument form Absolute value

For positive arguments, gives the remainder resulting from dividing the right- hand argument by the left-hand argument. When the arguments are of the opposite sign, the result is the complement of the result that you would get if they had the same sign. So for non-zero results, you must subtract the remainder from the divisor. (This operation is affected by ⎕CT, the comparison tolerance)

             3 | 10                  (The remainder of 10÷3)
       1
             7 | 24 5 0 25           (The remainder of dividing each
          3 5 0 4                     number in a vector by 7)
            3 17 2 | 5 20 3          (The remainder after dividing each
       2 3 1                          number in a vector by the corresponding
                                      number in another similar vector)
           ¯7 | ⍳ 10
      ¯6 ¯5 ¯4 ¯3 ¯2 ¯1 0 ¯6 ¯5 ¯4
            TABLE ← 2 3 ⍴ ⍳ 6        (The remainder of dividing each
           4 | TABLE                  number in a matrix by 4)
       1 2 3
       0 1 2
            TABLE | TABLE            (The remainder after dividing each
       0 0 0                          number in a matrix by the
       0 0 0                          corresponding number in another)
             2 |1 (2 2 ⍴⍳4) (⍳3)     (Divide every element by 2)
        1    1 0   1 0 1
             1 0
             2  3|2 (2 2 ⍴⍳4) (⍳3)   (Arguments must be of equal length)
       LENGTH ERROR
             2 3|2(2 2⍴⍳4)(⍳3)
             ^
             (2 2⍴⍳4) 3 (⍳3)|3 (2 2 ⍴⍳4) (3 2 1)
         0 1    1 2   0 0 1          (Corresponding elements divided)
         0 3    0 1

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