in the Homoiconic Spreadsheets Eli Parra gives an example of building up a "streak counter" using a calculation based on specific condition on the canvas (of the cell and its neighbours):
[is-checked]
[prev-streak] [= if (is-checked) then (prev-streak + 1) else 0]
- this could possibly mix very well with the ideas of "spatial queries" explored in the Programmable Ink (and Dynamicland), where a pattern like the one above wouldn't be copy-pasted around, but instead declared once (as a "match" on a specific configuration of the cells on the canvas)