#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
How to read it:
#tis the coordinate of the point being queried: att = 7,#tis 7, sosquareis 49 there.restrict … to (t : 10) endsays where the value exists: at the ten pointst = 0to9. Outside them there is no data, which eLucid8 calls eod (end of data). Sosquare[t = 10]is eod.halfissquaredivided by 2 at every point. It needs norestrictof its own: it exists wheresquaredoes.square[t = 7]is a question: the valuesquareat the pointt = 7.
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:
- The answer is there as the program opens, with no button to press:
square[t = 7] is 49. - Change the 7 in the question to 10 and run it again: eod, since there is no data at
t = 10. - Query
halfatt = 3: 4.5. - Look at Visualize:
squareis drawn as a row of ten cells with a line chart under it. Click a cell to query that point. - In the program, change
#t * #tto#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.