We compute a few verses of the Bottles of Beer song using Method paragraphs as both producers and consumers of data values.
First we define some quantities through givens and simple operations on them.
99 Bottles of Beer on the Wall -1 Take One Down Pass it Around SUM Bottles of Beer on the Wall -1 Take One Down Pass it Around SUM Bottles of Beer on the Wall
Then we retrieve values following wiki-centric scoping rules and continue the calculation.
Bottles of Beer on the Wall -1 Take One Down Pass it Around SUM Bottles of Beer on the Wall
Double-click a method to see what lines were used to create it.
Beer Constants
We can retrieve values from some data objects. For example, we can retrieve the first row of a dropped csv by citing the column header of the desired value.
We parametrize the last few verses of our song by citing a data for a Few or a Bunch of bottles. This is the fast way to get this tedious song finished.
Bottles of Beer on the Wall Take a Few Down SUM Bottles of Beer on the Wall Take a Few Down Take a Bunch Down SUM Bottles of Beer on the Wall
Note: More likely computations will be spread among a number of related pages. The computation performed will depend on the selection of pages and the order they appear.
Caution: We have yet to make the order of operations within methods reliably deterministic. If you see errors or unexpected values try refreshing the page.
The kid's travel song about sharing beer exposes lots of awkwardness in many programming languages. Learn how it is written in your language to get past these bumps.
We recreate in video the calculation refactoring example from the open source conference and invite viewers to try it themselves.