#Streams
The stream operators relate the positions of a value along one dimension: first, next and fby, and Lucid's wvr, asa and upon, which read a value at the positions where a condition is true. Each entry gives the form, a program with its answers, every rule, and the mistakes with their messages. The examples are read as How to read the examples says.
#Along a dimension
Does: these rules hold for all six operators.
Example:
-- file stream-rules.el8
-- Readings kept from t = 3 (the origin of t is still 0), and how fby groups.
reading = input("reading", t : 3 .. 6)
opening = first.t reading
before = 0 fby.t reading
n = 0 fby.t n + 1
steps = 1 fby.t 2 fby.t 3
-- table reading = t,value; 3,30; 4,40; 5,50; 6,60
-- expect opening = eod
-- expect before[t = 3] = eod
-- expect before[t = 4] = 30
-- expect n[t = 2] = 2
-- expect steps[t = 1] = 2
-- expect steps[t = 2] = 3
Answers:
| point | what is read | answer |
|---|---|---|
opening | reading at t = 0, outside its range 3 to 6 | eod |
before at t = 3 | reading at t = 2, outside its range | eod |
before at t = 4 | reading at t = 3 | 30 |
n at t = 2 | n + 1 at t = 1, as 0 fby.t (n + 1) | 2 |
steps at t = 1 | 2 fby.t 3 at t = 0 | 2 |
steps at t = 2 | 2 fby.t 3 at t = 1 | 3 |
Rules:
Each operator names the dimension it moves along, after a dot:
first.t e,next.t e,a fby.t b,y wvr.t q,y asa.t q,y upon.t q. Without the dimension, the compiler refuses the program (each entry's Mistakes give the message).The dimension's coordinates are whole numbers. Along a dimension whose coordinates are texts, the compiler refuses each of the six (for
fby: fby, Mistakes, 5).Every dimension's origin is position 0, whatever bound a value or an input has along it. An input over
t : 3 .. 6is eod at t = 0, so itsfirst.tis eod andfby.t's right operand reads eod at t = 3 (the example).fby,wvr,asaanduponbind asif … then … elsedoes: more loosely than every other operator exceptassertandin(Checking what a program assumes, Programs over several files). They group to the right. So in the example,nis0 fby.t (n + 1), andstepsis1 fby.t (2 fby.t 3):n = 0 fby.t n + 1 steps = 1 fby.t 2 fby.t 3From stream-rules.el8.
first.dandnext.dare prefixes, and bind as tightly as a minus sign before a number. Soriseis(next.t reading) - reading:rise = next.t reading - readingFrom next-rise.el8.
#first
Why: a value measured against where it started: each reading's change since the first, each price against the opening price.
Does: first.d e is e at d = 0, the same at every coordinate of d.
Form: first.d e, where d is a dimension of whole numbers that e varies along, and e is an expression.
Example:
-- file first-start.el8
-- Each reading's change since the first reading.
reading = input("reading", t : 4)
start = first.t reading
change = reading - first.t reading
at_zero = reading[t = 0]
-- table reading = t,value,ts; 0,20,1000; 1,22,2000; 2,25,3000; 3,21,4000
-- expect start = 20, at time 1000 ms
-- expect start[t = 3] = 20, at time 1000 ms
-- expect change[t = 2] = 5, at time 3000 ms
-- expect change[t = 4] = eod, at time 1000 ms
-- expect at_zero = 20, at time 1000 ms
Answers:
| point | reading there | start | change | at_zero |
|---|---|---|---|---|
no t | 20 (at 1000 ms) | 20 (at 1000 ms) | ||
| t = 2 | 25 (at 3000 ms) | 5 (at 3000 ms) | ||
| t = 3 | 21 (at 4000 ms) | 20 (at 1000 ms) | ||
| t = 4 | eod: past the bound | eod (at 1000 ms) |
Rules:
first.d eiseat the context withdset to 0, every other coordinate unchanged.The result does not vary along
d: it hase's dimensions exceptd. A query may namedor leave it out, with the same answer (startandstart[t = 3]).emust vary alongd; otherwise the compiler refuses the program (Mistakes, 2).eod: where
eat d = 0 is eod, the result is eod at every coordinate ofd(Along a dimension, rule 3).Missing data and errors: where
eat d = 0 is an error, the result is that error, naming its origin. A reading with no row inside the input's bound is such an error (Results):-- file first-gap.el8 -- No row at t = 0: the first reading is missing. reading = input("reading", t : 4) start = first.t reading -- table reading = t,value,ts; 1,22,2000; 2,25,3000; 3,21,4000 -- expect start = error missing from reading[t = 0]: input reading has no data at this pointThe timestamp: How operators combine them.
Mistakes:
- No dimension.
start = first readinggivesfirst works along a dimension, named after a dot: write first.d reading, with d that dimension. Fix: name the dimension,first.t reading. - A dimension
edoes not vary along.start = first.s readinggivesfirst.s moves along s, but its argument reading does not vary along s: the move has no effect. Fix: name a dimension ofreading,first.t.
Each wrong line above is a fragment of a program under Mistake programs.
Neighbours: reading[t = 0] gives the same answer (at_zero; Looking elsewhere). From first-start.el8. For the first position where a condition is true, rather than position 0, asa.
Lineage: first is Lucid's (W. W. Wadge and E. A. Ashcroft, Lucid, the Dataflow Programming Language, Academic Press, 1985), with the dimension named.
Mistake programs
-- file first-no-dimension.el8
-- Mistake 1: first with no dimension.
reading = input("reading", t : 4)
start = first reading
-- expect compile error: first works along a dimension, named after a dot: write first.d reading, with d that dimension
-- file first-other-dimension.el8
-- Mistake 2: first along a dimension its argument does not vary along.
reading = input("reading", t : 4)
start = first.s reading
-- expect compile error: first.s moves along s, but its argument reading does not vary along s: the move has no effect
#next
Why: a value compared with the one after it: how much each reading rises by the next, whether the next step is higher.
Does: next.d e is e one position ahead along d.
Form: next.d e, where d is a dimension of whole numbers that e varies along, and e is an expression.
Example:
-- file next-rise.el8
-- How much each reading rises by the next one; there is no row at t = 2.
reading = input("reading", t : 4)
ahead = next.t reading
rise = next.t reading - reading
ahead_too = reading[t = #t + 1]
-- table reading = t,value,ts; 0,20,1000; 1,22,2000; 3,21,4000
-- expect ahead[t = 0] = 22, at time 2000 ms
-- expect ahead[t = 1] = error missing from reading[t = 2]: input reading has no data at this point
-- expect ahead[t = 3] = eod
-- expect rise[t = 0] = 2, at time 2000 ms
-- expect rise[t = 2] = error missing from reading[t = 2]: input reading has no data at this point, at time 4000 ms
-- expect ahead_too[t = 0] = 22, at time 2000 ms
Answers:
| t | reading | ahead | rise | ahead_too |
|---|---|---|---|---|
| 0 | 20 (at 1000 ms) | 22 (at 2000 ms) | 2 (at 2000 ms) | 22 (at 2000 ms) |
| 1 | 22 (at 2000 ms) | Error via reading[t = 2]: missing | ||
| 2 | missing | Error via reading[t = 2]: missing (at 4000 ms) | ||
| 3 | 21 (at 4000 ms) | eod: t = 4 is past the bound |
Rules:
next.d eat d = c iseat the context with d = c + 1, every other coordinate unchanged.- The result has
e's dimensions. emust vary alongd; otherwise the compiler refuses the program with the message of first, Mistakes, 2, namingnext.- eod: where c + 1 is past
e's bound alongd, the result is eod (aheadat t = 3). - Missing data and errors: the result is the outcome of
eat c + 1, unchanged (aheadat t = 1). An operator that reads it is strict (Results):riseat t = 2 is the error too. - The timestamp: How operators combine them.
- Inside
fby's right operand, which is read one step back,next.d eiseat the current position (fby, rule 3).
Mistakes:
- No dimension.
ahead = next readinggivesnext works along a dimension, named after a dot: write next.d reading, with d that dimension. Fix:next.t reading. - A value defined from itself one step ahead.
x = restrict next.t x + #t to (t : 10) end: no message. Every point reads the point after it, up to the bound, wherexis eod, soxis eod at everyt. With no bound, a query never reaches a value: it stops at the demand-depth limit with a program error, not an answer. Fix: define a value from the step before, with fby.
Each wrong line above is a fragment of a program under Mistake programs.
Neighbours: reading[t = #t + 1] gives the same answer (ahead_too; Looking elsewhere). From next-rise.el8. To look back one step, fby.
Lineage: next is Lucid's (Wadge and Ashcroft, 1985), with the dimension named.
Mistake programs
-- file next-no-dimension.el8
-- Mistake 1: next with no dimension.
reading = input("reading", t : 4)
ahead = next reading
-- expect compile error: next works along a dimension, named after a dot: write next.d reading, with d that dimension
-- file next-ahead-of-itself.el8
-- Mistake 2: a value defined from itself one step ahead reads up to its bound, and is eod everywhere.
x = restrict next.t x + #t to (t : 10) end
-- expect x[t = 0] = eod
-- expect x[t = 9] = eod
#fby
Why: anything that grows step by step: a counter, a running total, a state carried from one step to the next.
Does: a fby.d b ("followed by") is a at d = 0, and at every later position b read one step back.
Form: a fby.d b, where d is a dimension of whole numbers and a and b are expressions; b may name the value being defined.
Example:
-- file fby-total.el8
-- A count of the steps, the running total of the readings, the reading before, and the change since it.
reading = input("reading", t : 4)
n = 0 fby.t n + 1
total = reading fby.t total + next.t reading
previous = 0 fby.t reading
change = error("no reading before t = 0") fby.t next.t reading - reading
back = reading[t = #t - 1]
so_far = sum reading over (t : 0 .. #t) end
-- table reading = t,value,ts; 0,20,1000; 1,22,2000; 2,25,3000; 3,21,4000
-- expect n[t = 3] = 3
-- expect n[t = 50] = 50
-- expect total[t = 0] = 20, at time 1000 ms
-- expect total[t = 1] = 42, at time 2000 ms
-- expect total[t = 3] = 88, at time 4000 ms
-- expect total[t = 4] = eod, at time 4000 ms
-- expect previous[t = 0] = 0
-- expect previous[t = 1] = 20, at time 1000 ms
-- expect change[t = 0] = error raised: no reading before t = 0
-- expect change[t = 1] = 2, at time 2000 ms
-- expect back[t = 0] = eod
-- expect so_far[t = 3] = 88, at time 4000 ms
Answers:
| t | reading | n | total | previous | change | back | so_far |
|---|---|---|---|---|---|---|---|
| 0 | 20 (at 1000 ms) | 20 (at 1000 ms) | 0 | Error: no reading before t = 0 | eod | ||
| 1 | 22 (at 2000 ms) | 42 (at 2000 ms) | 20 (at 1000 ms) | 2 (at 2000 ms) | |||
| 3 | 21 (at 4000 ms) | 3 | 88 (at 4000 ms) | 88 (at 4000 ms) | |||
| 4 | eod: past the bound | eod (at 4000 ms) | |||||
| 50 | 50 |
Rules:
At d = 0,
a fby.d bisaat the same context. At d = c, for c > 0, it isbat the context with d = c − 1, every other coordinate unchanged.Only the operand selected is evaluated:
aat d = 0,bat every later position. Sochangeat t = 1 is 2: the error on its left is never evaluated there.bis read one step back, coordinates included. Insideb,#dis c − 1,next.d eiseat c, and a name is its value at c − 1. Sototaladdsnext.t reading: one step back,nextgives the reading at the current step.total = reading fby.t total + next.t readingFrom fby-total.el8.
A value may name itself in
b: it then reads itself one step back, and is an iteration (n,total). A value that depends on itself at the same context is refused before evaluation (Mistakes, 1).The result varies along
d, and along every dimensionaandbvary along.Precedence: Along a dimension, rule 4.
eod: the result is the selected operand's outcome.
totalat t = 4 is eod, becausenext.t readingat t = 3 reads past the bound. With no bound written, a value defined withfbyhas no end:ncounts for ever (Values over contexts).Missing data and errors: the result is the selected operand's outcome (
changeat t = 0). An error read at one step of an iteration is passed on at every later step, naming its origin:-- file fby-gap.el8 -- A running total over readings with no row at t = 2. reading = input("reading", t : 4) total = reading fby.t total + next.t reading -- table reading = t,value,ts; 0,20,1000; 1,22,2000; 3,21,4000 -- expect total[t = 1] = 42, at time 2000 ms -- expect total[t = 2] = error missing from reading[t = 2]: input reading has no data at this point, at time 2000 ms -- expect total[t = 3] = error missing from reading[t = 2]: input reading has no data at this point, at time 4000 msThe timestamp: How operators combine them.
Mistakes:
- An equation that names itself at the same point.
total = total + readinggivesunguarded cycle: total -> total (a value cannot depend on itself at the same context). Fix:total = reading fby.t total + next.t reading. - The current reading on the right.
wrong = reading fby.t wrong + reading: no message. The right operand is read one step back (rule 3), so it adds the reading before, andwrongat t = 1 is 40, not 42. Fix:next.t reading. - The coordinate on the right.
fac = restrict 1 fby.n fac * #n to (n : 20) end: no message. At n = 1 the right operand reads#nas 0, sofacis 0 from n = 1 on. Fix:1 fby.n fac * (#n + 1), which gives 120 at n = 5. - No dimension.
n = 0 fby n + 1givesfby works along a dimension, named after a dot: write 0 fby.d n, with d that dimension. Fix:0 fby.t n + 1. - A dimension of texts.
s = 0 fby.zone sales, withzonelisted as{"north", "east"}, giveszone's coordinates are whole numbers here (fby.zone moves along it), but texts at 3:1 ("north" is listed as a coordinate of zone): a dimension's coordinates are all whole numbers or all texts, so use texts for zone here too, or give the whole numbers a dimension of their own. Fix: move along a dimension of whole numbers.
Each wrong line above is a fragment of a program under Mistake programs.
Neighbours: reading[t = #t - 1] reads one step back too, but is eod at t = 0 (back), where fby gives its left operand (Looking elsewhere). A total of every position so far is also sum reading over (t : 0 .. #t) end (so_far; Regions and aggregates). From fby-total.el8. To read a value at a slower rate, wvr and upon.
Lineage: fby is Lucid's: in Wadge and Ashcroft (1985), the Lucid equation x = 0 fby x + 1 is the counter 0, 1, 2, …. eLucid8 names the dimension, and calls a value defined this way an iteration.
Mistake programs
-- file fby-same-point.el8
-- Mistake 1: an equation that names itself at the same point.
reading = input("reading", t : 4)
total = total + reading
-- expect compile error: unguarded cycle: total -> total (a value cannot depend on itself at the same context)
-- file fby-current-reading.el8
-- Mistake 2: the current reading on the right of fby is read one step back.
reading = input("reading", t : 4)
wrong = reading fby.t wrong + reading
-- table reading = t,value,ts; 0,20,1000; 1,22,2000; 2,25,3000; 3,21,4000
-- expect wrong[t = 1] = 40, at time 1000 ms
-- file fby-coordinate.el8
-- Mistake 3: #n on the right of fby is read one step back too.
fac = restrict 1 fby.n fac * #n to (n : 20) end
good = restrict 1 fby.n good * (#n + 1) to (n : 20) end
-- expect fac[n = 5] = 0
-- expect good[n = 5] = 120
-- file fby-no-dimension.el8
-- Mistake 4: fby with no dimension.
n = 0 fby n + 1
-- expect compile error: fby works along a dimension, named after a dot: write 0 fby.d n, with d that dimension
-- file fby-text-dimension.el8
-- Mistake 5: fby along a dimension of texts.
sales = input("sales", zone : {"north", "east"})
s = 0 fby.zone sales
-- expect compile error: zone's coordinates are whole numbers here (fby.zone moves along it), but texts at 3:1 ("north" is listed as a coordinate of zone)
#The walk of wvr, asa and upon
Does: wvr, asa and upon find the positions along d where a condition q is true by a walk, with these rules.
Example:
-- file walk-gaps.el8
-- No row at t = 2 (missing) and an error at t = 4.
q = input("q", t : 8)
y = restrict 100 + #t to (t : 8) end
w = y wvr.t q
u = y upon.t q
p = restrict default(q, false, "missing") to (t : 8) end
w2 = y wvr.t p
-- table q = t,value,ts; 0,false,1000; 1,true,2000; 3,true,4000; 4,error: bad reading,5000; 5,true,6000; 6,false,7000; 7,true,8000
-- expect w[t = 0] = 101, at time 2000 ms
-- expect w[t = 1] = error missing from q[t = 2]: input q has no data at this point, at time 2000 ms
-- expect u[t = 2] = 101, at time 2000 ms
-- expect u[t = 4] = error missing from q[t = 2]: input q has no data at this point, at time 2000 ms
-- expect w2[t = 1] = 103, at time 4000 ms
-- expect w2[t = 2] = error data from q[t = 4]: bad reading, at time 5000 ms
Answers:
| point | the walk | answer |
|---|---|---|
w at t = 0 | q at 0 false, at 1 true: the first true position is 1 | 101 (at 2000 ms) |
w at t = 1 | q at 2 is missing, before a second true position | Error via q[t = 2]: missing (at 2000 ms) |
u at t = 2 | q at 0 and 1: one true position, so y at 1 | 101 (at 2000 ms) |
u at t = 4 | q at 0 to 3: q at 2 is missing | Error via q[t = 2]: missing (at 2000 ms) |
w2 at t = 1 | p passes over the gap: true at 1 and 3 | 103 (at 4000 ms) |
w2 at t = 2 | p at 4 is the error in the data | Error via p ← q[t = 4]: bad reading (at 5000 ms) |
Rules:
At a point with coordinate c along
d, the walk examinesqat positions 0, 1, 2, … alongd, in order, every other coordinate as at the point. Each entry says how far it walks and which position it readsyat.A position where
qistruecounts; one whereqisfalseis passed over.An eod in
qends the walk, and the result is eod: the condition's data has ended, so there is no later position to find.An error in
qis the result, naming its origin: the walk cannot know whether that position counts. A missing reading is such an error (wat t = 1). So the first of an eod and an error that the walk meets is the result.A
qthat is not a boolean gives the errorwvr needs a boolean condition(asa needs …,upon needs …).Past
q's bound alongd, the result is eod.Along a dimension declared
infin an input thatqreads, the walk looks only up to the last row alongd(Results):-- file walk-inf.el8 -- Readings with no end: the walk stops at the last row along t. reading = input("reading", t : inf) passed = reading wvr.t reading >= 20 -- table reading = t,value; 0,18; 1,21; 2,19; 3,24 -- expect passed[t = 1] = 24 -- expect passed[t = 2] = eodwvrandasaneedqbounded alongd, or reading an input alongd; otherwise the compiler refuses the program (wvr, Mistakes, 1).uponneeds neither: it examines only positions before c.To pass over missing readings rather than stop at them,
default(q, false, "missing")(w2; default).The timestamp: How operators combine them.
#wvr
Why: a value read only where a condition holds, renumbered: the readings that passed a check, one after another; the positions of the events.
Does: y wvr.d q ("whenever") at d = c is y at the (c + 1)th position along d where q is true.
Form: y wvr.d q, where d is a dimension of whole numbers, y an expression and q a condition.
Example:
-- file wvr-passed.el8
-- The readings of at least 20, one after another, and where each was.
reading = input("reading", t : 8)
ok = reading >= 20
passed = reading wvr.t ok
position = #t wvr.t ok
-- table reading = t,value,ts; 0,18,1000; 1,21,2000; 2,19,3000; 3,24,4000; 4,22,5000; 5,17,6000; 6,25,7000; 7,16,8000
-- expect passed[t = 0] = 21, at time 2000 ms
-- expect passed[t = 1] = 24, at time 4000 ms
-- expect passed[t = 3] = 25, at time 7000 ms
-- expect passed[t = 4] = eod, at time 8000 ms
-- expect position[t = 2] = 4, at time 5000 ms
Answers:
| t | reading | ok | passed | position |
|---|---|---|---|---|
| 0 | 18 | false | 21 (at 2000 ms) | |
| 1 | 21 | true | 24 (at 4000 ms) | |
| 2 | 19 | false | 4 (at 5000 ms) | |
| 3 | 24 | true | 25 (at 7000 ms) | |
| 4 | 22 | true | eod (at 8000 ms): no fifth | |
| 5 | 17 | false | ||
| 6 | 25 | true | ||
| 7 | 16 | false |
Rules:
- At d = c, the walk (The walk of wvr, asa and upon) goes on until it has met c + 1 true positions; the result is
yat the last of them, s, every other coordinate unchanged. - If the walk passes
q's bound first, the result is eod (passedat t = 4:okis true four times). - The result varies along
d. - eod, missing data and errors in
q: The walk, rules 3 to 6. Iny: the outcome ofyat s, unchanged. - The timestamp: How operators combine them.
Mistakes:
- A condition with no bound along
d.picked = level wvr.t every_third, withevery_third = mod(#t, 3) == 0, giveswvr.t searches along t, which has no end, and its condition reads no data along t; bound it: restrict … to (t : n) end. Fix:every_third = restrict mod(#t, 3) == 0 to (t : 20) end. - A condition that is not a boolean.
kept = reading wvr.t reading: no compile message; the answer isError: wvr needs a boolean condition. Fix: a comparison,reading wvr.t reading >= 20. - No dimension.
kept = reading wvr okgiveswvr works along a dimension, named after a dot: write reading wvr.d ok, with d that dimension. Fix:reading wvr.t ok.
Each wrong line above is a fragment of a program under Mistake programs.
Neighbours: for the first true position only, asa; to read y more slowly rather than skip its positions, upon. To combine the positions where a condition holds rather than list them, an aggregate with an if filter (Regions and aggregates).
Lineage: wvr ("whenever") is Lucid's (Wadge and Ashcroft, 1985). Where Lucid's wvr waits for ever for a true position that never comes, eLucid8 gives eod past the condition's bound.
Mistake programs
-- file wvr-no-bound.el8
-- Mistake 1: a condition with no bound along t.
level = restrict 10 * #t to (t : 20) end
every_third = mod(#t, 3) == 0
picked = level wvr.t every_third
-- expect compile error: wvr.t searches along t, which has no end, and its condition reads no data along t; bound it: restrict … to (t : n) end
-- file wvr-not-boolean.el8
-- Mistake 2: a condition that is a number.
reading = input("reading", t : 4)
kept = reading wvr.t reading
-- table reading = t,value; 0,18; 1,21; 2,19; 3,24
-- expect kept[t = 0] = error type: wvr needs a boolean condition
-- file wvr-no-dimension.el8
-- Mistake 3: wvr with no dimension.
reading = input("reading", t : 4)
ok = reading >= 20
kept = reading wvr ok
-- expect compile error: wvr works along a dimension, named after a dot: write reading wvr.d ok, with d that dimension
#asa
Why: the first time something happens: the first reading above a threshold, the first step of an iteration that is good enough.
Does: y asa.d q ("as soon as") is y at the first position along d where q is true, the same at every coordinate of d.
Form: y asa.d q, where d is a dimension of whole numbers, y an expression and q a condition.
Example:
-- file asa-first-pass.el8
-- The first reading of at least 20, and where it was.
reading = input("reading", t : 8)
ok = reading >= 20
first_ok = reading asa.t ok
where_ok = #t asa.t ok
never = reading asa.t reading > 100
first_ok_too = first.t (reading wvr.t ok)
where_ok_too = min #t over (t : 8) if ok end
-- table reading = t,value,ts; 0,18,1000; 1,21,2000; 2,19,3000; 3,24,4000; 4,22,5000; 5,17,6000; 6,25,7000; 7,16,8000
-- expect first_ok = 21, at time 2000 ms
-- expect first_ok[t = 5] = 21, at time 2000 ms
-- expect where_ok = 1, at time 2000 ms
-- expect never = eod, at time 8000 ms
-- expect first_ok_too = 21, at time 2000 ms
-- expect where_ok_too = 1, at time 8000 ms
Answers:
| value | the walk | answer |
|---|---|---|
first_ok | ok false at 0, true at 1 | 21 (at 2000 ms), at every t |
where_ok | the same | 1 (at 2000 ms) |
never | no reading above 100 at 0 to 7, then past the bound | eod (at 8000 ms) |
first_ok_too | wvr's walk at t = 0 | 21 (at 2000 ms) |
where_ok_too | not a walk: an aggregate over all eight readings | 1 (at 8000 ms) |
Rules:
y asa.d qisy wvr.d qat d = 0: the walk (The walk of wvr, asa and upon) goes on until the first true position s, and the result isyat s.- The result does not vary along
d: it hasy's andq's dimensions exceptd. A query may namedor leave it out, with the same answer (first_okandfirst_ok[t = 5]). - If the walk passes
q's bound first, the result is eod (never). - eod, missing data and errors in
q: The walk, rules 3 to 6. Iny: the outcome ofyat s, unchanged. - The timestamp: How operators combine them.
Mistakes:
- A condition with no bound along
d. As for wvr, Mistakes, 1, withasa.tin the message:asa.t searches along t, which has no end, and its condition reads no data along t; bound it: restrict … to (t : n) end. - No dimension.
first_ok = reading asa okgivesasa works along a dimension, named after a dot: write reading asa.d ok, with d that dimension. Fix:reading asa.t ok.
Each wrong line above is a fragment of a program under Mistake programs.
Neighbours: first.t (reading wvr.t ok) gives the same answer (first_ok_too). For the position, #t asa.t ok (where_ok), or min #t over (t : 8) if ok end (where_ok_too; Regions and aggregates), which reads every reading and so carries the latest timestamp. From asa-first-pass.el8. For position 0 whatever the condition, first.
Lineage: asa ("as soon as") is Lucid's; Wadge and Ashcroft (1985, p. 71) define y asa q as first(y wvr q).
Mistake programs
-- file asa-no-bound.el8
-- Mistake 1: a condition with no bound along t.
level = restrict 10 * #t to (t : 20) end
every_third = mod(#t, 3) == 0
picked = level asa.t every_third
-- expect compile error: asa.t searches along t, which has no end, and its condition reads no data along t; bound it: restrict … to (t : n) end
-- file asa-no-dimension.el8
-- Mistake 2: asa with no dimension.
reading = input("reading", t : 4)
ok = reading >= 20
first_ok = reading asa ok
-- expect compile error: asa works along a dimension, named after a dot: write reading asa.d ok, with d that dimension
#upon
Why: one stream consumed at the pace of another: the task worked on, moving to the next task after each tick where the current one finished.
Does: y upon.d q at d = c is y at the number of positions before c along d where q is true.
Form: y upon.d q, where d is a dimension of whole numbers, y an expression and q a condition.
Example:
-- file upon-tasks.el8
-- The task worked on at each tick: the next one after each tick where the task finished.
task = input("task", t : 8)
finished = input("finished", t : 8)
current = task upon.t finished
done = 0 fby.t done + (if finished then 1 else 0)
by_hand = task[t = done]
-- table task = t,value; 0,101; 1,102; 2,103; 3,104; 4,105; 5,106; 6,107; 7,108
-- table finished = t,value,ts; 0,false,1000; 1,true,2000; 2,false,3000; 3,true,4000; 4,true,5000; 5,false,6000; 6,true,7000; 7,false,8000
-- expect current[t = 0] = 101
-- expect current[t = 1] = 101, at time 1000 ms
-- expect current[t = 2] = 102, at time 2000 ms
-- expect current[t = 4] = 103, at time 4000 ms
-- expect current[t = 5] = 104, at time 5000 ms
-- expect current[t = 8] = 105, at time 8000 ms
-- expect current[t = 9] = eod, at time 8000 ms
-- expect by_hand[t = 5] = 104, at time 5000 ms
Answers:
| t | finished | true positions before t | current |
|---|---|---|---|
| 0 | false | 0 | 101 |
| 1 | true | 0 | 101 (at 1000 ms) |
| 2 | false | 1 | 102 (at 2000 ms) |
| 4 | true | 2 | 103 (at 4000 ms) |
| 5 | false | 3 | 104 (at 5000 ms); by_hand the same |
| 8 | eod: past the bound | 4 | 105 (at 8000 ms) |
| 9 | eod | needs finished at 8 | eod (at 8000 ms) |
Rules:
- At d = c, the walk (The walk of wvr, asa and upon) examines positions 0 to c − 1 and counts the true positions, m; the result is
yat d = m, every other coordinate unchanged. At c = 0 nothing is examined, and the result isyat 0. - So
ymoves on one position after each position whereqis true, and stays where it is after each whereqis false. - If the walk would examine a position past
q's bound, the result is eod (currentat t = 9 needsfinishedat 8). uponneeds no bound onq: it examines only positions before c.- The result varies along
d. - eod, missing data and errors in
q: The walk, rules 3 to 5. Iny: the outcome ofyat m, unchanged. - The timestamp: How operators combine them.
Mistakes:
- A condition that is not a boolean.
moved = task upon.t task: no compile message; from t = 1 the answer isError: upon needs a boolean condition. Fix: a condition,task upon.t finished. - No dimension.
current = task upon finishedgivesupon works along a dimension, named after a dot: write task upon.d finished, with d that dimension. Fix:task upon.t finished.
Each wrong line above is a fragment of a program under Mistake programs.
Neighbours: the same count written by hand is done = 0 fby.t done + (if finished then 1 else 0), read by task[t = done] (by_hand). From upon-tasks.el8. To skip y's positions where q is false rather than wait at them, wvr.
Lineage: upon is Lucid's (Wadge and Ashcroft, 1985).
Mistake programs
-- file upon-not-boolean.el8
-- Mistake 1: a condition that is a number.
task = input("task", t : 4)
moved = task upon.t task
-- table task = t,value; 0,101; 1,102; 2,103; 3,104
-- expect moved[t = 0] = 101
-- expect moved[t = 1] = error type: upon needs a boolean condition
-- file upon-no-dimension.el8
-- Mistake 2: upon with no dimension.
task = input("task", t : 4)
finished = input("finished", t : 4)
current = task upon finished
-- expect compile error: upon works along a dimension, named after a dot: write task upon.d finished, with d that dimension