# Lucid

## 1 Introduction

Weblogs Forum: Fluid Programming in Lucid -- good examples, and very good links.

Lucid page written by Bill Wadge, including an excerpt from Lucid Primer book.

Wikipedia article (yet a stub, but useful links).

## 2 Details

The most detailed online material on the details of this language I could find: Raganswamy Jagannathan, Chris Dodd. GLU programmer's guide (downloadable as the 4th paper of GIPSY Publications). The first pages seem to discuss other problems, but it is worth of reading further, because a detailed description of Lucid's syntax and semantics is hiding inside this paper (section 3.1.2 on pages 22--38). This paper is part of the Gipsy Project Home Page (GIPSY: A General Intensional Programming System).

## 3 Implementation

### 3.1 Fast-food

A fast-food implementation:

written to mimick and test the following Lucid example (I have made it a little Haskell-like -- it is not original Lucid syntax, but it is not an embedding into Haskell language, either -- in fact, it is a didactic intermediate syntax): ``` ```

``` average n = sum n / card sum n = first n `fby` (sum n + next n) card = 1 `fby` succ card ```

This program counts the moving average of the input stream:

 Snapshot Input Output 0 ` ` ` ` 1 `10` `10` 2 `10`, `20` `10`, `15` 3 `10`, `20`, `30`, `40` `10`, `15`, `20`, `25` 4 `10`, `20`, `30`, `40`, `50` `10`, `15`, `20`, `25`, `30`

In fact, `first`, `next`, `fby` are not necessarily primitives in Lucid, but this fast-food implementation treats them as primitives.

### 3.2 Arrow

A better implementation could be written using the arrow library available at the Downloads page of Arrows: A General Interface to Computation written by Antony Courtney, Henrik Nilsson and Ross Paterson.