The following conditional SequenceIterator methods apply the object's
booleansequence to the input sequence(s). These methods are of the following types:
- Ternary operation iif(), which takes two input sequence arguments, then and otherwise, and produces a result sequence of the same type by applying the
booleanelement in the object's condition sequence.- filter(), which returns a sequence of the same type as the input with only the elements corresponding to
trueelements in the object's condition sequence.- filterPos(), which returns an integer sequence with the positions of the
trueelements in the object's condition sequence.The following methods are available:
public SequenceIterator iif(SequenceIterator then, SequenceIterator otherwise, boolean lazy)Chooses the element of the then sequence or the otherwise sequence depending on the boolean value of the element of the object's condition sequence. All three sequences are traversed at the same speed (if the element of the then sequence is used, then the element of the otherwise sequence is skipped and vice versa). Please see the Ternary Operations page for further details.
public SequenceIterator filter(SequenceIterator cond)Returns a sequence of the same type as input with only the elements corresponding to
trueelements in the object's condition sequence.public SequenceIterator filterPos()Returns an integer sequence with the positions of the
trueelements in the object's condition sequence.Example
The following code snippet demonstrates a conditional method:
cursor = con.cursor("Quote", "by_sym") for quote in cursor: ... last = quote.day.last(); dayit = quote.day.search(DMY(1,MONTH(last),YEAR(last)), exdb.SeqIteratorBoundary.MCO_SEQ_BOUNDARY_INCLUSIVE, last, exdb.SeqIteratorBoundary.MCO_SEQ_BOUNDARY_INCLUSIVE) openit,closeit = dayit.project('open', 'close') gtit = closeit.gt(openit) filtit = gtit.filter(dayit) ...