Learn › Beginner · Lesson 4 of 11

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

Open in playground

How to read it:

Try it in the playground

  1. The answer is there as the program opens, with no button to press: change[t = 3] is -3.
  2. Press Why?: the trace shows the two readings change read, at t = 3 and t = 2, and nothing else. eLucid8 computed only what this answer needed.
  3. Query change at t = 0: eod.
  4. Query first_reading: there is no coordinate to give.
  5. Change #t - 1 to #t - 2 in change: 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.