## Programming with infinite arrays: Factorial

Here we give an example of programming with infinite arrays. We take the well-known factorial function, and calculate using tournament computation. The TransLucid source code is found below.

We build an array f which varies with respect to dimensions t and d, effectively creating a computation tree. For example, to compute the factorial of 3, the variable f becomes

```    d
t 1 1 2 3 1 1 ...
1 6 1 1 1 1 ...
6 1 1 1 1 1 ...
```

and the answer is 6, picked up when t=2 and d=0.

Similarly, for the factorial of 6, f becomes

```      d
t   1   1   2   3   4   5   6   1   1 ...
1   6  20   6   1   1   1   1   1 ...
6 120   1   1   1   1   1   1   1 ...
720   1   1   1   1   1   1   1   1 ...
```

and the answer is 720, picked up when t=3 and d=0.

When t = 0, the value of f is a d-stream such that f is the current d-index if it is between 1 to n, and 1 otherwise. When t > 0, the value of f is a d-stream such that f is the product of pairs from the (t-1) d-stream.

```fun fact.n = f
where
dim d <- 0 ;;
var f = tournamentOp₁.d.n.times (default₁.d.1.n.1 (#!d)) ;;
end ;;
```
Advertisement

## TransLucid preamble

There are now a number of TransLucid examples available at the TransLucid Web site.
All of these examples use the declarations found in the preamble.

http://translucid.web.cse.unsw.edu.au/examples/header.tl

## Publication archive

To help gather the open problems related to implementing TransLucid,
a publication archive has been prepared. It is available at
http://plaice.web.cse.unsw.edu.au/archive
Included in that archive are the collected works of John Plaice,
Blanca Mancilla and Bill Wadge, along with all of the papers
presented at the International Symposia on Lucid and
Intensional Programming
and the Conferences on
Distributed Communities on the Web
.

## The first release of TransLucid is out!

It has taken a long time to come, but the first release of TransLucid,
version 0.1.0, is out. It is available at the following link.
http://sourceforge.net/projects/translucid/files/TransLucid/0.1.0/tl-0.1.0.tar.bz2/download

c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel