nth()

Synopsis

Returns the nth item in list. The first item in a list has an index of 1. If i is 0 or negative, the first item is returned as well. If i is larger than the length of list, the last item is returned.

Syntax

nth ( i As Any; _
      list As Any ) As Any
Argument Type Description
i Any The index of the item to return.
list Any The list

Example 1

Intent >nth(3, {"a", "b", "c", "d", "e"})
--> "c"

Example 2

Intent >nth(1, {"a", "b", "c", "d", "e"})
--> "a"

Example 3

Intent >nth(0, {"a", "b", "c", "d", "e"})
--> "a"

Example 4

Intent >nth(-1, {"a", "b", "c", "d", "e"})
--> "a"

Example 5

Intent >nth(7, {"a", "b", "c", "d", "e"})
--> "e"

Example 6

Intent >nth(2.7, {"a", "b", "c", "d", "e"})
--> "b"
While the index can be a number, it is rounded down.