# Conditional C Sequence Functions

> The following conditional C API functions take one input sequence or two (then, else) sequences, and a boolean sequence condition. sequences of any TYPE listed in the Analytics Functions page, and a boolean sequence condition. The result sequence is of the specified TYPE except for the `mco_seq_filter_pos()` API which returns a result sequence of type `uint4`.

> The two input sequence iterator arguments must be of the same type and result is a sequence of values, or a scalar value. If the two input sequence arguments are of different lengths the operation will be performed on only the number of elements in the shorter of the two sequences.

> mco_seq_iif_TYPE() | Choose the element of the then sequence or the else sequence depending on the boolean value of the element of the condition sequence. All three sequences are traversed at the same speed (if the element of the "then" sequence is used, then the element of "else" sequence is skipped and visa versa). (Please see the Ternary Operations page for further details.)
> mco_seq_if_TYPE() | Choose the element of the then sequence or the else sequence depending on the boolean value of the element of the condition sequence. Unlike `mco_seq_iif_TYPE()`, the position in the sequence not used is not changed. (Please see the Ternary Operations page for further details.)
> mco_seq_filter_TYPE() | Leave only those elements of the input sequence for which the boolean elements of the cond sequence are true.
>         MCO_RET mco_seq_filter_TYPE(mco_seq_iterator_h result,
>                 mco_seq_iterator_h cond,
>                 mco_seq_iterator_h input);
> mco_seq_filter_search() | This function is used in combination with a generated `classname_fieldname_search()` function where the result of `classname_fieldname_search()`is passed as parameter search_result and the filter condition is passed in parameter cond
>         MCO_RET mco_seq_filter_search(mco_seq_iterator_h result,
>                  mco_seq_iterator_h cond,
>                 mco_seq_iterator_h search_result);
> mco_seq_filter_pos | Get positions of the elements that are `true` in sequence cond.
>         MCO_RET mco_seq_filter_pos(mco_seq_iterator_h result,
>                 mco_seq_iterator_h cond);

> ## Example

> Following is an example code snippet demonstrating a conditional function:

>         Quote_by_sym_index_cursor(trans, &quote_cursor);
>         for (rc = mco_cursor_first(trans, &quote_cursor);
>             rc != MCO_S_CURSOR_END;
>              rc = mco_cursor_next(trans, &quote_cursor))
>         {
>             /* Get current object */
>             Quote_from_cursor(trans, &quote_cursor, &quote);

>             /* Select interval */
>             Quote_day_last(&quote, &last);
>             Quote_day_search(&quote, &day_iterator, DMY(1, MONTH(last), YEAR(last)),
>                 MCO_SEQ_BOUNDARY_INCLUSIVE,
>                 last,
>                 MCO_SEQ_BOUNDARY_INCLUSIVE);
>             Quote_open_project(&quote, &open_iterator, &day_iterator);
>             Quote_close_project(&quote, &close_iterator, &day_iterator);

>             /* Construct operator's pipeline */
>             mco_seq_gt_float(&gt_iterator, &close_iterator, &open_iterator);
>             mco_seq_filter_uint4(&filter_iterator, &gt_iterator, &day_iterator);

>             ...
>         }
>         rc = mco_trans_commit(trans);