# Path: makeQuantity.py
# def     makeScalar(value, prototype=(0,)):
#     """
#     make an APL scalar quantity from a scalar Python value
#     """
#     if isinstance(value, aplQuantity):
#         assertError("makeScalar: needs more thought")
# 
#     try:
#         value = value.__iter__().__next__()
#     except AttributeError:
#         pass
# 
#     return aplQuantity((value,), None, prototype)
# 
# def     makeVector(value, length=-1, prototype=(0,)):
#     """
#     make an APL vector quantity from a Python list
#     """
#     if length is None:
#         length = 1
# 
#     if not isinstance(value, (tuple, lookAhead)):
#         if length < 0 or prototype is None:
#             value = lookAhead(value, 1)
# 
#     if isinstance(value, lookAhead):
#         if length < 0:
#             if value.buffered() == 0:
#                 length = 0
# 
#         if prototype is None:
#             if value.buffered() == 0:
#                 assertError("ASSERTION ERROR: makeVector()")
#             prototype = (makePrototype(value.peek()),)
# 
#     elif isinstance(value, list):
#         value = tuple(value)
# 
#     if length == 0:
#         return makeEmptyVector(prototype)
# 
#     if not isinstance(value, (tuple, lookAhead)):
#         value = lookAhead(value, 1)
# 
#     return aplQuantity(value, length, None)
# 
# def     makePrototype(value):
#     """
#     the 'array prototype' for this value
#     """
#     if isinstance(value, aplQuantity):
#         prototype = value.makePrototype()
# 
#         return aplQuantity(prototype, len(prototype), prototype)
# 
#     return ' ' if isinstance(value, str) else 0
# 
# Path: aplError.py
# def     assertNotTrue(condition, error):
#     """
#     raise error if condition is true
#     """
#     if condition:
#         raise aplException(error)
# 
# def     assertNotArray(X, error="RANK ERROR"):
#     """
#     throw if quantity is a higher order array
#     """
#     if X.isArray():
#         raise aplException(error)


import operatorIterators as iterator
from makeQuantity import makeScalar, makeVector, makePrototype
from aplError import assertNotTrue, assertNotArray
        if B.isEmptyVector():
            return B

        if B.isScalarLike():
            return makeScalar(B.scalarToPy())

        Rpy = iterator.scanVector(Fn, B)

        return makeVector(Rpy, B.dimension(), B.prototype())

    assertNotArray(B, "WIP - RANK ERROR")

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

def     scanFirst(Fn, _, B):
    """
    the map for the ⍀ (scan along first axis) operator
    """
    if B.isScalar():
        return B

    if B.isVector():
        if B.isEmptyVector():
            return B

        if B.isScalarLike():
            return makeScalar(B.scalarToPy())

        Rpy = iterator.scanVector(Fn, B)


# Path: makeQuantity.py
# def     makeScalar(value, prototype=(0,)):
#     """
#     make an APL scalar quantity from a scalar Python value
#     """
#     if isinstance(value, aplQuantity):
#         assertError("makeScalar: needs more thought")
# 
#     try:
#         value = value.__iter__().__next__()
#     except AttributeError:
#         pass
# 
#     return aplQuantity((value,), None, prototype)
# 
# def     makeVector(value, length=-1, prototype=(0,)):
#     """
#     make an APL vector quantity from a Python list
#     """
#     if length is None:
#         length = 1
# 
#     if not isinstance(value, (tuple, lookAhead)):
#         if length < 0 or prototype is None:
#             value = lookAhead(value, 1)
# 
#     if isinstance(value, lookAhead):
#         if length < 0:
#             if value.buffered() == 0:
#                 length = 0
# 
#         if prototype is None:
#             if value.buffered() == 0:
#                 assertError("ASSERTION ERROR: makeVector()")
#             prototype = (makePrototype(value.peek()),)
# 
#     elif isinstance(value, list):
#         value = tuple(value)
# 
#     if length == 0:
#         return makeEmptyVector(prototype)
# 
#     if not isinstance(value, (tuple, lookAhead)):
#         value = lookAhead(value, 1)
# 
#     return aplQuantity(value, length, None)
# 
# def     makePrototype(value):
#     """
#     the 'array prototype' for this value
#     """
#     if isinstance(value, aplQuantity):
#         prototype = value.makePrototype()
# 
#         return aplQuantity(prototype, len(prototype), prototype)
# 
#     return ' ' if isinstance(value, str) else 0
# 
# Path: aplError.py
# def     assertNotTrue(condition, error):
#     """
#     raise error if condition is true
#     """
#     if condition:
#         raise aplException(error)
# 
# def     assertNotArray(X, error="RANK ERROR"):
#     """
#     throw if quantity is a higher order array
#     """
#     if X.isArray():
#         raise aplException(error)


# Path: operatorMaps.py
import operatorIterators as iterator
from makeQuantity import makeScalar, makeVector, makePrototype
from aplError import assertNotTrue, assertNotArray

        if B.isEmptyVector():
            return B

        if B.isScalarLike():
            return makeScalar(B.scalarToPy())

        Rpy = iterator.scanVector(Fn, B)

        return makeVector(Rpy, B.dimension(), B.prototype())

    assertNotArray(B, "WIP - RANK ERROR")

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

def     scanFirst(Fn, _, B):
    """
    the map for the ⍀ (scan along first axis) operator
    """
    if B.isScalar():
        return B

    if B.isVector():
        if B.isEmptyVector():
            return B

        if B.isScalarLike():
            return makeScalar(B.scalarToPy())

        Rpy = iterator.scanVector(Fn, B)


        return makeVector(Rpy, B.dimension(), B.prototype())