programlibs/Ranges/demos/sampled.xtl

Every third reading from a sensor log, by index: for i:=0..len(v)-1 by 3 binds i to the stride (0, 3, 6, ...); (1 + i) s_elect v reads them (X_eTaL arrays are 1-origin, the range 0-origin as it is written). Run with "just demo Ranges sampled".

source · imports rg: libs/Ranges/src/Ranges.xtlm

v : Int

value · line 8
v ← 10 12 9 14 20 7 15 22 11 18 25 6

i : Int

value · line 9
@ ʳᵍf̲or< "for i:=0..len(v)-1 by 3"
ʳᵍf̲or< expands to
i ← 0 + (3 × ((r̲ange (1 + f̲loor ((((t̲ally v) − 1) − 0) ÷ 3))) − 1))