left ... (parameter set function)

Prev Next

Function Names

left , left include , left last match , left last match include

Description

This function extracts a left 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 left [string function] instead.

2
input
numeral parameter set position

Positive: Select the first 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: 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 left ...: Return the left part of the parameter set without the matching element.
Function left include ...: Return the left 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 element 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( left( set[], 0 ), ", ", left( set[], 1 ), ", ", left( set[], -2 ), ", ", left( set[], -1 ) );
      echo( left( set[],99 ), ", ", left( set[], -99) );
      echo;
      echo( left( set[], { 12, of } ), " / ", left include( set[], { 12, of } ) ); // Recognized 'of' as 1st match
      echo( left last match ( set[], {the} ), ", ", left last match include( set[], {the} ) );
      echo( left( set[], {tea } ) ); // Returns full set because element 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: ", left( set[], {of}, set2[], set3[] ) );
      echo( "Extraction 2: ", set2[] );
      echo( "Extraction 3: ", set3[] );

Output

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

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

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

See also

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