You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/posts/calculating-spilled-arrays/index.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: "Calculating spilled arrays in a spreadsheet"
3
3
summary: ""
4
4
author: "Prabhanshu Gupta"
5
-
lastmod: 2024-01-26
5
+
lastmod: 2024-02-01
6
6
---
7
7
8
8
A spreadsheet formula can evaluate to a single value or an array of values. When it evaluates to an array, the result is "spilled" into neighbouring cells underneath. Here's an example
@@ -133,7 +133,7 @@ When a spiller evaluates to an array of values
133
133
134
134
Whenever a cell is evaluated, we evaluate the `interested-spillers` in addition to other formula dependents. This can be done by adding `interested-spillers` to the depgraph as a reval dependent.
135
135
136
-
Note that while spilling, if a cell is already spilled into we return a `Spill Error`. This ensures that the first edited formula stays spilled and future spillers don't.
136
+
Note that while spilling, if a cell is already spilled into we return a `Spill Error`. This ensures that the oldest formula stays spilled and future spillers don't.
137
137
138
138
## Detecting circular dependencies
139
139
@@ -155,9 +155,9 @@ Let's look at how a cycle can manifest with spilled arrays.
155
155
156
156
1.`D5` refers to `B1:D3` and spills into `E6`.
157
157
2.`E6` gets the value `105` since `C2` is `5`.
158
-
3. A formula is entered into `C2` that refers to `E6` (here is the loop).
158
+
3. A formula is entered into `C2` that refers to `E6` (here is the cycle).
159
159
160
-
Upon evaluating `C2` we'll go into a cycle. Here's the depgraph.
160
+
Upon evaluating `C2` we'll enter a loop. Here's the depgraph.
Hang on a second. If you follow the arrows though, there's clearly no cycle in the depgraph. How come?
@@ -182,7 +182,7 @@ A working implementation of all this can be found [here](https://github.com/nile
182
182
[^excel-dynamic-arrays]: [Dynamic array formulas and spilled array behavior](https://support.microsoft.com/en-us/office/dynamic-array-formulas-and-spilled-array-behavior-205c6b06-03ba-4151-89a1-87a7eb36e531) – support.microsoft.com
183
183
[^google-array-formulas]: In Google Sheets, you can wrap a formula in an [`ARRAYFORMULA`](https://support.google.com/docs/answer/3093275?hl=en) to achieve the same result. Sheets has had the feature for very long (at least since 2009) while Excel introduced this in 2018.
184
184
[^sestoft-calls-it-a-support-graph]: It's called a `Support graph` in [Spreadsheet Implementation Technology](https://direct.mit.edu/books/book/3071/Spreadsheet-Implementation-TechnologyBasics-and) by Peter Sestoft.
185
-
[^phases]: We can mark two "phases" in a spreadsheet's evaluation. A first pass, when we start with a sheet full of formula strings and no other information. All the cells in a sheet need to be evaluated in _some_ order (row-major, let's say). The first pass sets up the stage for any incremental re-evaluations. <br><br> Once a first pass is done, each cell update causes an incremental re-evaluation. We tackle incremental re-evaluations first. The first pass can then be expressed as incremental evaluations over each cell starting with a blank sheet.
185
+
[^phases]: We can mark two "phases" in a spreadsheet's evaluation. A first pass, when we start with a sheet full of formula strings and no other information. All the cells in a sheet need to be evaluated in _some_ order (row-major, let's say). The first pass sets up the stage for any incremental re-evaluations. <br><br> Once a first pass is done, each cell update causes an incremental re-evaluation. We tackle incremental re-evaluations here. The first pass can then be expressed as incremental evaluations over each cell starting with a blank sheet.
186
186
[^lord-io]: [How to recalculate a spreadsheet](https://lord.io/spreadsheets/), lord.io
187
187
[^sestoft]: Once a first pass is done, each cell update causes an incremental re-evaluation. We tackle incremental re-evaluations first. The first pass can then be expressed as incremental evaluations over each cell starting with a blank sheet.
0 commit comments