Learn › Beginner · Lesson 1 of 11

A value over a dimension

An eLucid8 program is a set of equations. Each equation defines a value over dimensions: a named axis such as t (time, or steps, or anything you count), and a result at every point along it. You can query any value at any point: in the playground, choose the value after Ask for, give its point after at (square at t = 7), and press Run query (the program's own question is asked by itself when it opens); eLucid8 computes that answer and only what it needs. Or see a whole picture of it with Visualize.

-- A value over one dimension.
square = restrict #t * #t to (t : 10) end
half = square / 2
-- ask square[t = 7]
-- expect square[t = 7] = 49
-- expect square[t = 10] = eod
-- expect half[t = 3] = 4.5

Open in playground

How to read it:

The lines starting with -- are comments. On these pages, -- ask names a good first query, and -- expect lines say what the answers are.

Try it in the playground

Press Open in playground under the program, then:

  1. The answer is there as the program opens, with no button to press: square[t = 7] is 49.
  2. Change the 7 in the question to 10 and run it again: eod, since there is no data at t = 10.
  3. Query half at t = 3: 4.5.
  4. Look at Visualize: square is drawn as a row of ten cells with a line chart under it. Click a cell to query that point.
  5. In the program, change #t * #t to #t * 3. Once you stop typing, the row redraws by itself. Undo brings the square back.

Ask your own AI

With an assistant that has eLucid8's tools or reference (see Building with your own AI):

Using eLucid8's reference at https://elucid8-lang.org/llms.txt, write a Beginner eLucid8 program (equations only: no input or output lines) with a value over t from 0 to 19 that is 3 times t plus 1. Compile it with the elucid8 tools before you show it, and give me its Open in playground link.