outside ... (set function)

Prev Next

Function Names

outside , outside exclude , outside until , outside until exclude

Description

This function extracts a outside part of the set either with two element position numbers or matching elements or a combination of both. More precisely, is is the opposite of the middle [set function].

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

4

Parameters

No.TypeDescription
1
input
set input set

Attention: If 1st parameter is not a set, please refer to outside [string function] instead.

2
input
numeral starting element position

Positive: First part of the subset ends before this position (0 = 1st element, 1 = 2nd element, etc.)
Larger than number of elements: complete set returned
Negative: Starting position counted from right to left, e.g. -1 = last element
Smaller than minus number of elements in set: Begins with 1st element
The function name ending '... exclude' will be ignored.

Alt. 2
input
set starting matching elements

Function outside ...: First part of the set ends including the starting matching element.
Function outside exclude ...: First part of the set ends before the starting matching element.
Empty sets are interprested as per se found.

If this function parameter contains 2 or more elements, then the set will be compared with all elements and the first match with any of these elements will apply.
Function name ending ... last match: Looks for the last matching elements in the set and not the first one.

3
input
numeral element count or ending element position

For function names outside until, this parameter contains the ending element position. Negative numbers count from right to left: -1 = 2nd part begins behind last element (= nothing), -2 = 2nd part begins behind 2nd last element (last element included).
Element positions before the starting position of found element will return the full sets.
For function names not containing until, this parameter contains the element count. 0 and negative numbers complete sets.

The function name ending '... exclude' will be ignored.

Alt. 3
input
set ending matching elements

Function outside ...: 2nd part of the set begins including the ending matching element.
Function outside exclude ...: 2nd part of the set begins after the ending matching element.
Empty sets means no further matches and the full original set is returned.

Attention: The function names ending outside until combined with matching elements provided will assert errors.

If this function parameter contains 2 or more elements, then the set will be compared with all elements and the first match with any of these elements will apply.
Function name ending ... last match: Looks for the last matching element in the set and not the first one. Empty sets are interprested as per se found.

Opt. 4+
io
set follower

Other sets in addition to the one provided as the first function parameter can be extracted in the same same way. Add any number of additional set variables. They will be manipulated at the exact same positions as the returned value.

Return value

TypeDescription
set Extracted subset

Examples

               set[] = { the, taste, of, the, 12, coffees, '!' };

               echo( outside( set[], 4,  2 ), " / ", outside until( set[], 1, 5 ) );
               echo( outside( set[], -3, 2 ), " / ",  outside until( set[], -6, -2 ) );
               echo;
               echo( outside( set[],  99, 3 ), " / ",  outside until ( set[],  99, 3 ) ); // empty sets
               echo( outside( set[], -99, 3 ), " / ",  outside until ( set[], -99, 3 ) ); // the taste of / ... the
               echo;
               echo( outside( set[], {taste}, 4 ), " / ", outside exclude( set[], {taste}, 4 ) ); // 4 elements in both cases
               echo( outside until( set[], {taste}, -2 ), " / ", outside until exclude( set[], {taste}, -2 ) );
               echo( outside ( set[], {taste}, {coffees} ), " / ", outside exclude( set[], {taste}, {coffees} ) );

               echo( outside ( set[], {}, {coffees} ), " / ", outside exclude( set[], {taste}, {} ) );
               echo( outside ( {}, {}, {coffees} ), " / ", outside exclude( {}, {taste}, {} ) ); // empty sets
               echo;
               echo( "Demonstrate the follower feature: ");

               set2[] = { A, fragrance, coming, from, 120, espressos, '!' };
               set3[] = { Der, Geschmack, kommt, von, 120, Tassen Kaffee, '!' };

               echo( "Extraction 1: ", outside( set[], {of}, 3, set2[], set3[] ) );
               echo( "Extraction 2: ", set2[] );
               echo( "Extraction 3: ", set3[] );

Output

{'the','taste','of','the','!'} / {'the','!'}
{'the','taste','of','the','!'} / {'the','!'}

{'the','taste','of','the',12,'coffees','!'} / {'the','taste','of','the',12,'coffees','!'}
{'the',12,'coffees','!'} / {12,'coffees','!'}

{'the','taste','!'} / {'the','coffees','!'}
{'the','taste','!'} / {'the','!'}
{'the','taste','coffees','!'} / {'the','!'}
{'coffees','!'} / {'the','taste','of','the',12,'coffees','!'}
{} / {}

Demonstrate the follower feature:
Extraction 1: {'the','taste','of','!'}
Extraction 2: {'A','fragrance','coming','!'}
Extraction 3: {'Der','Geschmack','kommt','!'}
Try it yourself: Open LIB_Function_outside_.b4p in B4P_Examples.zip. Decompress before use.

See also

left [set function]
right [set function]
middle [set function]
outside [string function]