Learn › Beginner · Lesson 7 of 11

No data, and errors

Every answer in eLucid8 is one of three things:

There is no silent NaN or empty cell: a gap is eod, a failure is an error.

-- Gaps, a division by zero, and what to do about them.
gappy = restrict if mod(#t, 4) == 3 then eod else #t to (t : 12) end
ratio = 12 / gappy
missing = restrict iseod(gappy) to (t : 12) end
filled = restrict default(gappy, 0) to (t : 12) end
checked = if gappy > 8 then error("too high") else gappy
eod_wins = gappy + 1 / (#t - 3)
-- ask ratio[t = 0]
-- expect gappy[t = 3] = eod
-- expect ratio[t = 4] = 3
-- expect ratio[t = 0] = error division: division by zero
-- expect ratio[t = 3] = eod
-- expect missing[t = 3] = true
-- expect filled[t = 3] = 0
-- expect checked[t = 9] = error raised: too high
-- expect checked[t = 7] = eod
-- expect eod_wins[t = 3] = eod
-- expect eod_wins[t = 4] = 5

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: ratio[t = 0] is an error, division by zero.
  2. In Visualize, look at ratio's row: eod and the error are drawn apart from the numbers, and from each other.
  3. Press Why? on the error: the trace shows where it started.
  4. Query filled and compare its row with gappy's: the gaps are 0.

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) with ten made-up readings where two are missing (eod), and a value that fills each gap with the reading before it. Compile it with the elucid8 tools before you show it, and give me its Open in playground link.