lst_take(L;N)

Returns a list-value containing a given number of elements.

Syntax

lst_take(L;N)

Input

Argument Type Description
L list-value The name of the list-value whose indexed values will be returned

If L is omitted, an error is returned.

If L is N/A, an error is returned.

A list-value

N integer The number of indexed elements to return, starting at 1 and returning up to and including element N

If N is negative, the index counting begins at the end of the list-value takes the through the N'th to last element.

If N is omitted, an error is returned.

If N is N/A, an error is returned.

A scalar value

Return Value

Returns the first N elements of L as a comma-separated list.

Sample Usage

The following example demonstrates how the lst_take(L;N) function returns a list-value of the first three elements in list.

<let list="{lst(1 'a' 'A' 3.14159)}">
  <willbe name="element_values" value="'{lst_take(@list;3)}'"/>
</let>

The code above creates a computed column with the value: 1,a,A.

Example: Get the values from the first N elements of list-value L

Once a list-value is created, values up to any index position can be retrieved using the lst_take(L;N) function.

<let list="{lst('hop' 'skip' 'jump')}" distance="2">
  <willbe name="howfar" value="'{lst_take(@list;@distance)}'"/>
</let>

The code above creates a computed column with the value: hop,skip.