sourcelibs/Ranges/demos/sampled.xtl

1⍝!/usr/bin/env xetal 2⍝│ Every third reading from a sensor log, by index: for i:=0..len(v)-1 3⍝│ by 3 binds i to the stride (0, 3, 6, ...); (1 + i) s_elect v reads 4⍝│ them (X_eTaL arrays are 1-origin, the range 0-origin as it is 5⍝│ written). Run with "just demo Ranges sampled". 6 7"rg:" u̲se< "Ranges" 8v ← 10 12 9 14 20 7 15 22 11 18 25 6 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))
10i ⍝ the indices sampled 11(1 + i) s̲elect v ⍝ the readings at them