ExprAsArray Method

Converts the Expr to an array of the requested type and depth.

Definition

Namespace: Wolfram.NETLink
Assembly: Wolfram.NETLink (in Wolfram.NETLink.dll) Version: 2.0.0.0
C#
public Array AsArray(
	ExpressionType reqType,
	int depth
)

Parameters

reqType  ExpressionType
The type of the leaf elements. Must be ExpressionType.Integer or ExpressionType.Real.
depth  Int32
The desired depth of the array. Must be 1 or 2.

Return Value

Array

Remarks

The requested element type must be either ExpressionType.Integer or ExpressionType.Real, and the depth must be 1 or 2. In other words, 1- or 2-dimensionals arrays of integers or doubles can be extracted from an Expr object using this method.

Some Exprs represent large lists or arrays of integers or reals. This method is the only efficient way of extracting the raw array data from out of the Expr. To preserve the immutability of Exprs, however, the returned array is a copy of the Expr's internal array data.

Exceptions

ArgumentExceptionIf depth > 2 or the requested type is not supported.
ExprFormatExceptionIf the Expr cannot be converted to this format.

See Also