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 __init__(self, A, B, P): self._A = A self._B = B.__iter__() if A >= 0 else lookAhead(B, -A, P) self._P = P if A < 0: try: while True: self._B.pushThenPop() except StopIteration: pass
def isString(self): """ true if quantity really is a string """ if self.padFill() == 0: return False if isinstance(self._value, tuple): for element in self._value: if not isinstance(element, str): return False return True if not isinstance(self._value, lookAhead): self._value = lookAhead(self._value) return self._value.isString()
def __init__(self, A, B): self._A = A self._B = B.__iter__() if A >= 0 else lookAhead(B, -A)
def __init__(self, A, B): self._A = A self._B = lookAhead(B) self._L = len(A)
def __init__(self, A, B): self._B = B.__iter__() self._L = lookAhead(self._B, A)