#Looking elsewhere: x[t = …]
A value can read another value at a different point. reading[t = #t - 1] is reading one step back: at t = 3 it is the reading at t = 2.
-- The previous reading, and the change since it.
reading = restrict 20 + mod(#t * 7, 5) to (t : 10) end
previous = reading[t = #t - 1]
change = reading - reading[t = #t - 1]
first_reading = reading[t = 0]
-- ask change[t = 3]
-- expect previous[t = 1] = 20
-- expect change[t = 3] = -3
-- expect change[t = 0] = eod
-- expect first_reading = 20
How to read it:
readingis the ten readings of Data written as formulas: 20, 22, 24, 21, 23, ….changeatt = 3is the reading at 3 (21) minus the reading at 2 (24): −3.- At
t = 0there is no step before: a coordinate below 0 has no data, soreading[t = -1]is eod, and so ischangethere. eod passes through arithmetic: anything computed from it is eod too. first_readingsetstto 0, whatever the question says. It does not depend ontat all, so it has no dimensions: you query it by its name alone,first_reading, and it is 20. eLucid8 works out each value's dimensions from its equation.
#Try it in the playground
- The answer is there as the program opens, with no button to press:
change[t = 3] is -3. - Press Why?: the trace shows the two readings
changeread, att = 3andt = 2, and nothing else. eLucid8 computed only what this answer needed. - Query
changeatt = 0: eod. - Query
first_reading: there is no coordinate to give. - Change
#t - 1to#t - 2inchange: the row redraws by itself, the change over two steps.
#Ask 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) that compares each of ten made-up readings with the one two steps earlier. Compile it with the elucid8 tools before you show it, and give me its Open in playground link.