extend("array")

# Basic usage: array:nth(index, data)
sput( array:nth(0, ["A", "B", "C"]) )
# => "A"
sput( array:nth(-1, ["A", "B", "C"]) )
# => "C"  (last element)

# If out of range, it returns '_', i.e. a Placeholder.

# Partial usage examples:
# 1) Provide only the index
getThird = array:nth(2)
sput( getThird([10,20,30,40]) )
# => 30

nthFromArr = array:nth(_, [5,6,7,8])
sput( nthFromArr(-2) )

# 3) Provide neither argument => returns a partial function requiring 2 calls
nthFunc = array:nth()

# Then apply the index:
idxFunc = nthFunc(1)

# Then apply the array:
sput( idxFunc(["Alpha","Beta"]) )
# => "Beta"
