Converts the specified enumeration into another enumeration, in which some of the source elements may be passed unchanged, some removed and some replaced with new elements produced from the corresponding old ones.

The ordering of elements in the result enumeration will correspond to the original one.

Parameters:

e

Specify the source enumeration
elemVar
The reference to the variable, through which each source enumeration element is passed to acceptQuery and elemQuery subqueries (below).

The variable reference must be produced using '@' operator (see example below).

acceptQuery
Specify the subquery, to test whether a source element must be accepted into the result enumeration or skipped over.

The subquery should be prepared using BooleanQuery() function (see example below). It will be executed for each element from the source enumeration. The tested element is received in subquery via the variable, whose reference must be specified in the elemVar parameter.

The subquery must return true to indicated that the element is accepted or false to remove it.

When this parameter is null, all source elements will be accepted.

elemQuery
Specify the subquery, using which you can replace some of the source elements with new ones.

The subquery should be prepared using FlexQuery() function (see example below). It will be executed for each accepted element from the source enumeration. The element is received in subquery via the variable, whose reference must be specified in the elemVar parameter.

Any result returned by the subquery will be treated as the element added to the result enumeration in place of the original element.

In particular, you may return the original element itself or any other value produced from it. Returning the null is also possible, which will equally get into the result enumeration.

When this parameter is not specified or null, all accepted elements will get into result enumeration as is.

Returns:

The result enumeration.

In case when no elements are accepted or the source enumeration is null, the result will be the empty enumeration.

See Also:

FlexQuery(), BooleanQuery()

Example:

The following expression converts an enumeration of some numbers into another enumeration, in which only positive initial numbers are accepted and then rounded to integer.


numbers = Enum (-1, 4.1, 0, 1.31, 2.9, -7.4 );

convertEnum (
  numbers, 
  @(Number) number,
  BooleanQuery (number > 0),
  FlexQuery (round (number))
);
This will return the following enumeration:

{ 4, 1, 3 }