19.11.2014 Views

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A = [1 2 3; 4 5 6; 7 8 9]<br />

then A 1,0 evaluates to 4 .<br />

An array of two dimensions whose elements are a subtype of Number can be coerced to a matrix. Matrix types<br />

are written MatrixT[n 0 × . . . × n k−1 ] , where k > 1. A type of this form can be abbreviated as T n 0×...×n k−1<br />

.<br />

Matrices are indexed in the same manner as arrays.<br />

A one-dimensional array whose elements are a subtype of Number can be coerced to a vector. Vector types are written<br />

VectorT[n] . A type of this form can be abbreviated as T n , unless T is declared in the enclosing scope to be a<br />

physical dimension or unit.<br />

<strong>The</strong> element expressions in an array expression may be either scalars or array expressions themselves. If an element is<br />

an array expression, it is “flattened” (pasted) into the enclosing expression. This pasting works because arrays never<br />

contain other arrays as elements. <strong>The</strong> elements along a row (or column) must have the same number of columns<br />

(or rows), though two elements in different rows (columns) need not have the same number of columns (rows). See<br />

Section 6.5 for a discussion of matrix unpasting.<br />

<strong>The</strong> following four examples are all equivalent:<br />

[3 4<br />

5 6]<br />

[3 4 ;<br />

5 6 ]<br />

Here is a 3 × 3 × 3 × 2 matrix example:<br />

[1 0 0<br />

0 1 0<br />

0 0 1 ; ; 0 1 0<br />

1 0 1<br />

0 1 0 ; ; 1 0 1<br />

0 1 0<br />

1 0 1<br />

; ; ;<br />

1 0 0<br />

0 1 0<br />

0 0 1 ; ; 0 1 0<br />

1 0 1<br />

0 1 0 ; ; 1 0 1<br />

0 1 0<br />

1 0 1 ]<br />

[ 3 4<br />

; 5 6 ]<br />

[3 4 ; 5 6]<br />

Tuple Expressions:<br />

Syntax:<br />

Aggregate ::= (Expr( , Expr) + )<br />

| ([Expr( , Expr) ∗ , ] Expr ... )<br />

| ([Expr( , Expr) ∗ , ] [Expr ... , ] Id = Expr ( , Id = Expr) ∗ )<br />

Tuple element expressions are enclosed in parentheses and separated by commas. Each element is one of:<br />

• A plain expression “ e ”<br />

• A varargs expression “e...”<br />

• A keyword-value pair “identifier = e ”<br />

113

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!