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.

• Left-associate the remaining elements of the juxtaposition.<br />

(Note that this process requires type analysis of newly created chunks along the way.)<br />

Here is an (admittedly contrived) example: reduce(f)(a)(x + 1)sqrt(x + 2) . Suppose that reduce is a curried function<br />

that accepts a function f and returns a function that can be applied to an array a (the idea is to use the function<br />

f , which ought to take two arguments, to combine the elements of the array to produce an accumulated result).<br />

<strong>The</strong> leftmost function is reduce , and the following element (f ) is parenthesized, so the two elements are replaced with<br />

one: (reduce(f))(a)(x + 1)sqrt(x + 2) . Now type analysis determines that the element (reduce(f)) is a function.<br />

<strong>The</strong> leftmost function is (reduce(f)) , and the following element (a) is parenthesized, so the two elements are replaced<br />

with one: ((reduce(f))(a))(x + 1)sqrt(x + 2) . Now type analysis determines that the element ((reduce(f))(a))<br />

is not a function.<br />

<strong>The</strong> leftmost function is (sqrt) , and the following element (x + 2) is parenthesized, so the two elements are replaced<br />

with one: ((reduce(f))(a))(x + 1)(sqrt(x + 2)) . Now type analysis determines that the element (sqrt(x + 2)) is<br />

not a function.<br />

<strong>The</strong>re are no functions remaining in the juxtaposition, so the remaining elements are left-associated:<br />

(((reduce(f))(a))(x + 1))(sqrt(x + 2))<br />

Now the original juxtaposition has been reduced to binary juxtaposition expressions.<br />

16.8 Overview of Operators in the <strong>Fortress</strong> Standard Libraries<br />

This section provides a high-level overview of the operators in the <strong>Fortress</strong> standard libraries. See Appendix F for the<br />

detailed rules for the operators provided by the <strong>Fortress</strong> standard libraries.<br />

16.8.1 Prefix Operators<br />

For all standard numeric types, the prefix operator + simply returns its argument and the prefix operator − returns<br />

the negative of its argument.<br />

<strong>The</strong> operator ¬ is the logical NOT operator on boolean values and boolean intervals.<br />

<strong>The</strong> operator ¬ computes the bitwise NOT of an integer.<br />

Big operators such as ∑ begin a reduction expression (Section 13.18). <strong>The</strong> big operators include ∑ (summation)<br />

and ∏ (product), along with ⋂ , ⋃ , ∧ , ∨ , ∨ , ⊕ , ⊗ , ⊎ , ⊞ , ⊠ , MAX , MIN , and so on.<br />

16.8.2 Postfix Operators<br />

<strong>The</strong> operator ! computes factorial; the operator !! computes double factorials. <strong>The</strong>y may be applied to a value of any<br />

integral type and produces a result of the same type.<br />

When applied to a floating-point value x , x! computes Γ(1 + x) , where Γ is the Euler gamma function.<br />

132

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

Saved successfully!

Ooh no, something went wrong!