3 ms·
So inspiring! Makes me pine for more exploratory programming. Nowadays this would be done with a spreadsheet, which seems like such overkill when you compare to
by fusiongyro 10y ago
So inspiring! Makes me pine for more exploratory programming. Nowadays this would be done with a spreadsheet, which seems like such overkill when you compare to this tiny bit of awk. A really pretty and concise demonstration of a completely different way to compute.
- throwanem 10y agoI'd do it in org-mode, with a table of data and a short code block to do the summing. (Probably not in awk, although it's probably an option; most things are. Table formulas are also an option; I don't use them as often, but for this they're a good fit.) It's a great environment for exploratory programming, not least because it abstracts away tedious stuff like file marshaling. You name your data source, bind it to a variable name in the code block header, and then just use it. A data source can be another code block, too, so complex multistage transforms are still easy to express. (It's also great for producing a throwaway prototype to validate an idea and demonstrate the result, without ever having to fear you'll be asked to promote it into production. When the first step in doing that is to install Emacs, even the most gung-ho manager grasps that this is the wrong shortcut to take.)
- fusiongyro 10y agoI've been using org-mode for about a year and I haven't got a clue what you're talking about.
- throwanem 10y agoI've been using it for quite a while longer than that, and I'm still discovering new functionality on a regular basis. If you're unfamiliar as yet with tables and source blocks in org-mode, you're missing out on a fair bit that might be of use to you. Tables support a wide array of functionality that normally requires a dedicated spreadsheet tool or custom code, and inline evaluation of source blocks enables a wide array of functionality around exploratory and literate programming. I use both almost daily, and the quality of the results and the speed with which they're produced regularly astonishes my colleagues, who are not familiar with such powerful tools and the capabilities they confer. (And lest I be perceived as bragging in this last claim, let me hasten to note that I'm not talking up myself - I'm no blazing fireball in the brains department, and as serious Emacs users go I'm barely more than a tyro - but rather talking up the amazing things which even someone barely more than a tyro can achieve with org-mode, and the efficiency with which such a person can do so.) Take a quick look, if you care to, at the relevant [1] sections [2] of the manual. Perhaps you'll find these tools useful! And if not, then at least you'll have some better idea of the superpowers which rest at your very fingertips, should you in future find yourself with a need to lay your hands upon them. [1] http://orgmode.org/manual/Tables.html http://orgmode.org/manual/Tables.html [2] http://orgmode.org/manual/Working-With-Source-Code.html http://orgmode.org/manual/Working-With-Source-Code.html