⍝   S t a n d a r d   E x c e l - s t y l e   d e f i n i t i o n s

⍝ Macros:

    round(num sig → mul←÷10*sig ⋄ mul×⌊0.5+num÷mul)

    floor(num mul → mul×⌊num÷mul)

    ceiling(num mul → mul×⌈num÷mul)

    sum(+/) max(⌈/) min(⌊/)     ⍝ sum(i, j, k,···)

    mod(n m → m | n)

⍝ Arithmetic:

      -(-)                      ⍝ neg (unary minus)
    → ∧(*)                      ⍝ pow
    ← *(×) /(÷)                 ⍝ mul div
    ← +(+) -(-)                 ⍝ add sub

    ← ,()                       ⍝ argument separator

⍝ Test cases:
⍝
⍝   round(2/3, 2)                    -> 0.67    ⍝ round to 2 sig figs
⍝   floor(123.456, 0.01)             -> 123.45  ⍝ floor to nearest hundredth
⍝   ceiling(123.456, 0.1)            -> 123.5   ⍝ ceiling to nearest tenth
⍝   sum(min(1,2,3),max(4,5,6),7,8,9) -> 31      ⍝ sum, min, max
⍝   mod(10,7)                        -> 3       ⍝ (remainder)
⍝   -2                               -> ¯2      ⍝ negate
⍝   2+-2                             -> 0       ⍝ neg binding
⍝   2∧2∧3                            -> 256     ⍝ power associates right
⍝   6/3*2                            -> 4       ⍝ div/mul associate left
⍝   6-3+2                            -> 5       ⍝ add/sub associate left
⍝   (6/(3*2)) ∧ (6-(3+2))            -> 1       ⍝ parentheses
⍝
⍝ Error cases:
⍝
⍝   2 3  !! missing operator
⍝   +3   !! missing operand
⍝   3+   !! missing operand
⍝   ()   !! null expression
⍝   1/0  !! bad operand
⍝   2(3) !! missing operator
⍝   (2)3 !! missing operator
⍝   3)   !! unexpected )
⍝   ((3  !! missing ))
⍝   
⍝   Back to: Contents