Silverfrost Logo About Us | Contact Us
 

PACK

Platform

x64, Win32, .NET

Purpose

To pack a given array into an array of rank one.

Class

Transformational function.

Syntax

FUNCTION PACK(ARRAY, MASK [, VECTOR])
LOGICAL MASK

Description

ARRAY is an array of any type. MASK is a logical array that is conformable with ARRAY. VECTOR is optional. VECTOR and the result of the function are arrays of rank one with the same type and type parameters as ARRAY.

If VECTOR is absent the size of the result is equal to the number of elements of MASK that are true. If VECTOR is present then the size of the result is equal to the size of VECTOR which must not be less than the number of elements of MASK that are true.

Return value

The result is a one-dimensional array obtained by selecting those values of ARRAY for which the corresponding element in MASK is true. VECTOR can be used to provide default values for the result after the point at which packing ceases.

Example

If M = then PACK(M, MASK=M>2) gives [4, 5, 3, 6].

If also V=[0, 0, 0, 0, 0] then PACK(M, MASK=M>2, VECTOR=V) gives [4, 5, 3, 6, 0].

 

 

Copyright © 1999-2017 Silverfrost Limited