Lucid is a dataflow programming language designed to experiment with non-von Neumann programming models. It was designed by Bill Wadge and Ed Ashcroft and described in the 1985 book Lucid, the Dataflow Programming Language., Lucid can be thought of as a multidimensional programming language, where time is one of its many dimensions. Lucid, viewed this way, can naturally express multidimensional computation that not only vary in time but in other dimensions. The examples below illustrate the power of Lucid in expressing a wide range of multidimensional computations.

Prime Numbers

<syntaxhighlight lang="text">

primes where

dimension i;

primes = first.i sieve;

natsFrom2 = i+2;

sieve = natsFrom2 fby.time

( sieve wvr.i ( sieve mod ( ( first.i sieve ) ne 0 ) ) );

end

</syntaxhighlight>

Merge Sort

<syntaxhighlight lang="text">

r0t8.v,time( output )

where

dimension v,h,t;

output = mergeSort asa.t inputSize == sizeOfMerge;

merge(x,y) = if iseod xx then yy

else if iseod yy then xx

else if xx <= yy then xx else yy fi fi fi

where

xx = x upon.v iseod yy || xx <= yy;

yy = x upon.v iseod xx || xx > yy;

end;

mergeSort = Inputdata(h) fby.t

merge(leftChild.h(mergeSort), rightChild.h(mergeSort));

sizeOfMerge = 1 fby.t 2*sizeOfMerge;

r0t8.a,b( x ) = x @.a b;

end

</syntaxhighlight>

Matrix Multiplication

<syntaxhighlight lang="text">

( matmult( A, B, n ) @.aux_i r ) @.aux_j c where

dimension aux_i, aux_j;

matmult( aux_a, aux_b, n ) = c asa.t s == (n*n*n) where

dimension t, i, j, k;

s = 1 fby.t 8*s;

d = 1 fby.t 2*d;

a = r0t8.aux_i.i( r0t8.aux_j.j( aux_a ) );

b = r0t8.aux_i.i( r0t8.aux_j.j( aux_b ) );

c = (a @.j k) * (b @.i k)

fby.t

( ( reduce @.k (2*k) ) @.j (2*j) ) @.i (2*i) where

reduce = block( c + next.k c,

next.j c + next.k next.j c,

next.i c + next.k next.i c,

next.j next.i c + next.k next.j next.i c,

d

);

block( tl, tr, bl, br, d ) = p where

p = append.aux_i( append.aux_j( tl, tr, d ),

append.aux_j( bl, br, d ),

d

);

append.dim( a, b, d ) = if( dim < d ) then a

else b @.dim (dim-d) fi;

end;

end;

r0t8.a.b( x ) = x @.a b;

end;

end

</syntaxhighlight>

References

  • , pLucid

<!-- Hidden categories below -->