datacell
define-cell
set-cell!
8.12

datacell🔗ℹ

Spencer Florence <spencer@florence.io>

 (require datacell) package: datacell

This package gives a simple embedded dataflow language based around the notion of “cells”, similar to the concept of a cell in a Spreadsheet.

A simple example:

Examples:
> (define-cell a 0)
> (define-cell b 2)
> (define-cell c 0)
> (define-cell d (- (expt b 2) (* 4 a c)))
> d

4

> (set-cell! a 1)
> (set-cell! c 1)
> d

0

syntax

(define-cell name body ...)

Defines a new cell name, who’s value will be computed by body .... If the body uses any other cells, the then the value of name will be recomputed if the value of those cells change.

A cells value is computed on demand, which is to say that body is only evaluated when the value of named is needed. The value of a cell is almost memoized, meaning body is only evaluated if the current value is not known or a cell used by the body has changed.

syntax

(set-cell! cell body)

Change the value in cell, which must be an identifier defined by define-cell. The rules for when body is evaluated are the same for definef-cell.