a port of the Processing Visualization Language
Name

subset()

Examples
String[] sa1 = { "OH ", "NY ", "CA ", "VA ", "CO ", "IL "};
String[] sa2 = subset(sa1, 1);
println(sa2);  // Prints NY, CA, VA, CO, IL
println();
String[] sa3 = subset(sa1, 2, 3);
println(sa3);  // Prints CA, VA, CO
Description

Extracts an array of elements from an existing array. The array parameter defines the array from which the elements will be copied and the offset and length parameters determine which elements to extract. If no length is given, elements will be extracted from the offset to the end of the array. When specifying the offset remember the first array element is 0. This function does not change the source array.

When using an array of objects, the data returned from the function must be cast to the object array's data type. For example: SomeClass[] items = (SomeClass[]) subset(originalArray, 0, 4).

Syntax
subset(array,offset)

subset(array,offset,length)
Parameters
array boolean[], byte[], char[], int[], float[], String[], or an array of objects
offset int: position to gebin
length int: number of values to extract
Returns Array (the same datatype as the input)
Usage Web & Application
Related splice()

This reference is licensed under the CC BY-NC-SA 2.0 license:

Creative Commons License
Fork me on GitHub