F-Script is an object-oriented programming and array programming language, implemented as a scripting framework for the Mac OS X object system (Cocoa). The F-Script interpreter is also a handy desk calculator. Here are a few snippets.

The syntax of F-Script is based on that of SmallTalk. Everything is an object, and computation is effected by sending messages to objects. For example, to take the square root of two, you send a "2" object the "sqrt" message. This is what it looks like when you do this in the F-Script interpreter:

> 2 sqrt 1.414213562373095

There are also binary messages (`+ - * /`

etc.) that go between objects.
All of the binary messages have equal
precedence and evaluate from left to right:

> 1 - 2 * 3 -3

In the above, object "1" is sent the "-" message with object "2" as an argument. This produces object "-1", which is then sent the "*" message with object "3" as an argument.

The binary messages have lower precedence than unary ones, so the following is how you can evaluate five plus the fourth root of two:

> 5 + 2 sqrt sqrt 6.189207115002721

Lowest precedence goes to so-called keyword expressions, which are message patterns like "raisedTo:". Here is an example:

> 1 + 0.5 / 2 raisedTo: 2 sqrt 0.665748113117505

First the "2 sqrt" is evaluated because it is a unary message. Then the "1 + 0.5 / 2" is evaluated because it is a binary message sequence, then the "raisedTo:" is evaluated. It is important to note that the keyword message "raisedTo:" has lower precedence than a binary message. Parentheses can be used to override the precedence.

The real power of F-Script is its array programming features. As a very simple example, you can get the square root of numbers 0 through 9 by

> 10 iota sqrt {0, 1, 1.4142135624, 1.7320508076, 2, 2.2360679775, 2.4494897428, 2.6457513111, 2.8284271247, 3}

and you can do sophisticated manipulations like finding values in an array in a certain range:

> a := 10 iota sqrt. > a at: (a between: 2 and: 2.5) {2, 2.2360679775, 2.4494897428}

All the wonderful APL operations like scanning, reduction, sorting are part of F-Script. But what I have described so far does not touch upon the real power of F-Script, and its raison d'etre, which is array programming. Using the "@" symbol, messages can be directed to objects inside arrays, or to objects inside arrays that are themselves inside arrays.