@Subset (JavaScript)

Subsets a list from left to right.

Defined in

@Functions (JavaScript)

Syntax

@Subset(list:any, length:int) : any
Parameter Description
list A list.
length The number of members in the new list. Cannot be 0. A negative number is treated as positive. A specification exceeding the list length means the entire list.
Return value Description
any The new list.

Usage

A list is an array.

Examples

This example subsets a list up to and including a specified member.
function p(stuff) {
	print("<<<" + stuff + ">>>"); 
 }

var cities = @List("Paris", "Berlin", "Moscow", "London");
var city = "Berlin";
var n = @Member(city, cities);
if(n > 0) {
	var citiesSubset = @Subset(cities, n);
	for(var i = 1; i <= @Count(citiesSubset); i++) {
		p(@Element(citiesSubset, i));
	}
} else {
	p(city + " is not listed");
}
/*
<<<Paris>>>
<<<Berlin>>>
*/