# Miscellaneous C Sequence Functions

> The following functions take a variety of input sequence arguments and produce result sequences or scalar types as described in the table below:

> mco_seq_histogram_TYPE() | Build a histogram for the input sequence. Minimal (inclusive) and maximal (exclusive) values for input sequence should be specified as well as the number of intervals (histogram columns). (The number of intervals should not be greater than tile size)
>         MCO_RET mco_seq_histogram_TYPE(
>                 mco_seq_iterator_h result,
>                 mco_seq_iterator_h input,
>                 TYPE min_value,
>                 TYPE max_value,
>                 size_t n_intervals);
> mco_seq_sort_TYPE() | Sort the sequence elements previously extracted using `mco_seq_get()` and construct a permutation array (of positions) that can be used to access the elements of other sequences (also extracted to arrays)
>         MCO_RET mco_seq_sort_TYPE(TYPE const* elems,
>                 mco_seq_no_t* permutation,
>                 mco_size_t n_elems);
> mco_seq_order_by_TYPE() | Sort the sequence elements using a permutation produced by `mco_seq_sort()`. If the `data` parameter is NULL, this function extracts all sequence elements to an array and then creates an iterator through this array according to the given permutation. The created array should be removed by a reset method. If the `data` parameter is not NULL, then the input iterator is ignored and data is taken from this array.
>         MCO_RET mco_seq_order_by_TYPE(mco_seq_iterator_h result,
>                  mco_seq_iterator_h input,
>                 mco_seq_no_t* permutation,
>                 mco_size_t n_elems,
>                 TYPE* data);
> The following group of C API functions apply a specific operation via function pointer func to a single input sequence or to two input sequences, left and right. They produce result sequences or scalar types as described in the table below: For APIs `mco_seq_func2_TYPE()` and `mco_seq_func2_ctx_TYPE()` the two input sequences must be of the same type. If the two input sequences are of different lengths the operation will be performed on only the number of elements in the shorter of the two sequences.
> mco_seq_func_TYPE() | Apply the function pointed to by argument func to the input sequence and produce result sequence of the same TYPE
>         MCO_RET mco_seq_func_TYPE(mco_seq_iterator_h result,
>                 mco_seq_iterator_h input,
>                 mco_seq_func_TYPE_ptr_t func);
> mco_seq_func2_TYPE() | Apply the function pointed to by argument func to the left and right sequences and produce result sequence of the same TYPE
>         MCO_RET mco_seq_func2_TYPE(mco_seq_iterator_h result,
>                 mco_seq_iterator_h left,
>                 mco_seq_iterator_h right,
>                 mco_seq_func_TYPE_ptr_t func);
> mco_seq_func_ctx_TYPE | Apply the function pointed to by argument func to the input sequence using the context pointed to by ctx and produce result sequence of the same TYPE
>         MCO_RET mco_seq_func_TYPE(mco_seq_iterator_h result,
>                 mco_seq_iterator_h input,
>                 mco_seq_func_TYPE_ptr_t func,
>                 void* ctx);
> mco_seq_func2_ctx_TYPE | Apply the function pointed to by argument func to the input sequence using the context pointed to by ctx and produce result sequence of the same TYPE
>         MCO_RET mco_seq_func2_ctx_TYPE(mco_seq_iterator_h result,
>                 mco_seq_iterator_h left,
>                 mco_seq_iterator_h right,
>                 mco_seq_func_TYPE_ptr_t func,
>                 void* ctx);
> mco_seq_cond_TYPE() | Evaluate boolean predicate function pointed to by argument func to the input sequence and produce result sequence of type `boolean`
>         MCO_RET mco_seq_cond_TYPE(mco_seq_iterator_h result,
>                 mco_seq_iterator_h input,
>                 mco_seq_cond_TYPE_ptr_t func);
> mco_seq_cond_ctx_TYPE() | Evaluate boolean predicate function pointed to by argument func to the input sequence using the context pointed to by ctx and produce result sequence of type `boolean`
>         MCO_RET mco_seq_cond_ctx_TYPE(mco_seq_iterator_h result,
>                 mco_seq_iterator_h input,
>                 mco_seq_func_TYPE_ptr_t func,
>                 void* ctx);
> mco_seq_hash() | Calculate the 32-bit hash code for each value of input sequence and produce a result sequence of type `uint4`. This function can combine the hash with a previously calculated hash for another sequence (if the hash argument is not null).
>         MCO_RET mco_seq_hash(mco_seq_iterator_h result,
>                 mco_seq_iterator_h input,
>                 mco_seq_iterator_h hash);

> ## Example

> Following is an example code snippet demonstrating one of these functions:

>         {
>             mco_trans_h trans;
>             mco_cursor_t quote_cursor;
>             Quote quote;
>             mco_seq_iterator_t high_iterator, result_iterator;
>             MCO_RET rc;
>             float max = 142.54;
>             float min = 24.13;
>             int n_intervals = 20;
>             ...

>             for (rc = mco_cursor_first(trans, &quote_cursor);
>                 rc != MCO_S_CURSOR_END;
>                 rc = mco_cursor_next(trans, &quote_cursor))
>             {
>                 Quote_from_cursor(trans, &quote_cursor, &quote);
>                 Quote_high_iterator(&quote, &high_iterator);
>                 ...
>                 rc = mco_seq_histogram_float(&result_iterator,  &high_iterator, max, min, n_intervals);

>                 ...
>             }
>             ...
>         }