# Path: aplError.py
# def     assertError(message):
#     """
#     raise an exception so aborting the current operation
#     """
#     raise aplException(message)


import dyadicMaps as mapper
import dyadicFunctions as dyadic
import dyadicIterators as iterator
from aplError import assertError
    '/':        (None, lambda A, B: mapper.compressLast(iterator.compress, A, B)),
    '⌿':        (None, lambda A, B: mapper.compressFirst(iterator.compress, A, B)),
    '\\':       (None, lambda A, B: mapper.expandLast(iterator.expand, A, B)),
    '⍀':        (None, lambda A, B: mapper.expandFirst(iterator.expand, A, B)),
    '⍋':        (None, lambda A, B: mapper.grade(False, A, B)),
    '⍒':        (None, lambda A, B: mapper.grade(True, A, B)),
    '⌷':        (None, _toBeImplemented),  # index

    # Miscellaneous
    '⍺':        (None, _toBeImplemented),  # picture format
    '⍕':        (None, _toBeImplemented),  # dyadic (specification) format
    '⍎':        (None, _toBeImplemented),  # dyadic execute
    '⊤':        (None, lambda A, B: mapper.encode(iterator.encode, A, B)),
    '⊥':        (None, lambda A, B: mapper.decode(iterator.decode, A, B)),
    '⊣':        (None, lambda A, B: A),
    '⊢':        (None, lambda A, B: B),
}

# ------------------------------

def     dyadicFunction(symbol):
    """
    return the dyadic function given its APL symbol

    raises INVALID TOKEN if the symbol is not recognised
    """

    try:
        return _DyadicFunctions[symbol[0]]
    except ZeroDivisionError:

# Path: aplError.py
# def     assertError(message):
#     """
#     raise an exception so aborting the current operation
#     """
#     raise aplException(message)


# Path: dyadicLookup.py
import dyadicMaps as mapper
import dyadicFunctions as dyadic
import dyadicIterators as iterator
from aplError import assertError

    '/':        (None, lambda A, B: mapper.compressLast(iterator.compress, A, B)),
    '⌿':        (None, lambda A, B: mapper.compressFirst(iterator.compress, A, B)),
    '\\':       (None, lambda A, B: mapper.expandLast(iterator.expand, A, B)),
    '⍀':        (None, lambda A, B: mapper.expandFirst(iterator.expand, A, B)),
    '⍋':        (None, lambda A, B: mapper.grade(False, A, B)),
    '⍒':        (None, lambda A, B: mapper.grade(True, A, B)),
    '⌷':        (None, _toBeImplemented),  # index

    # Miscellaneous
    '⍺':        (None, _toBeImplemented),  # picture format
    '⍕':        (None, _toBeImplemented),  # dyadic (specification) format
    '⍎':        (None, _toBeImplemented),  # dyadic execute
    '⊤':        (None, lambda A, B: mapper.encode(iterator.encode, A, B)),
    '⊥':        (None, lambda A, B: mapper.decode(iterator.decode, A, B)),
    '⊣':        (None, lambda A, B: A),
    '⊢':        (None, lambda A, B: B),
}

# ------------------------------

def     dyadicFunction(symbol):
    """
    return the dyadic function given its APL symbol

    raises INVALID TOKEN if the symbol is not recognised
    """

    try:
        return _DyadicFunctions[symbol[0]]
    except ZeroDivisionError:

        assertError("DOMAIN ERROR")