right ... (parameter set function)

Prev Next

Function Names

right , right include , right last match , right last match include

Description

This function extracts a right part of the parameter set either with a element position number or a subset resembling a matching element.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

Min 2

Parameters

No.TypeDescription
1
input
parameter set input parameter set

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

2
input
numeral parameter set position

Positive: Select the last n elements of the parameter set.
Larger than number of elements in the parameter set: Full parameter set returned
Negative: Keep number of elements counted from the right (-1 = all except last element)
Smaller than minus number of elements in parameter set: Empty set returned
Zero: Empty set returned

The function name ending '... include' will be ignored. Using the function name part '... last match ...' will assert an error.

Alt. 2
input
parameter set matching elements

Function right ...: Return the right part of the parameter set without the matching element.
Function right include ...: Return the right part of the parameter set including the matching element.
Empty sets are interpreted as no matches. The full set will be returned


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 pattern in the parameter set and not the first one.

Opt. 3+
io
parameter set follower

Other parameter 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 parameter set variables. They will be manipulated at the exact same positions as the returned value.

Return value

TypeDescription
parameter set Extracted subset

Examples

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

      echo( right( set[], 0 ), ", ", right( set[], 1 ), ", ", right( set[], -2 ), ", ", right( set[], -1 ) );
      echo( right( set[],99 ), ", ", right( set[], -99) );
      echo;
      echo( right( set[], { 12, of } ), " / ", right include( set[], { 12, of } ) ); // Recognized 'of' as 1st match
      echo( right last match ( set[], {the} ), ", ", right last match include( set[], {the} ) );
      echo( right( set[], {tea } ) ); // Returns full set because pattern not found

      echo( new line, "Demonstrate the follower feature: ");

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

      echo( "Extraction 1: ", right include ( set[], {the}, set2[], set3[] ) );
      echo( "Extraction 2: ", set2[] );
      echo( "Extraction 3: ", set3[] );

Output

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

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

Demonstrate the follower feature:
Extraction 1: {'the','taste','of','the',12,'coffees','!'}
Extraction 2: {'A','fragrance','coming','from',120,'espressos','!'}
Extraction 3: {'Der','Geschmack','kommt','von',120,'Tassen Kaffee','!'}
Try it yourself: Open LIB_Function_right_.b4p in B4P_Examples.zip. Decompress before use.

See also

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