|
Absolutely! Suppose I'm editing a text file, and I'm working through a tradeoff
between data volume and accuracy, where more accuracy requires
more data. I have an array of 14 sensors, and I can configure them
to take either 100-byte samples or 500-byte samples, and I can take
samples at intervals between 1 and 60 seconds. So I make myself a little table: sensors size interval
14 100 1
14 100 30
14 100 60
Then I duplicate it: sensors size interval
14 100 1
14 100 30
14 100 60
14 100 1
14 100 30
14 100 60
I'm using kakoune, so I can put my cursor on the 100 in the first
duplicate row, press C twice, then press r5, and now I have this table: sensors size interval
14 100 1
14 100 30
14 100 60
14 500 1
14 500 30
14 500 60
Now, I want to know bytes per day, and this is where the math comes in.
I start adding columns. First I duplicate the three existing columns,
since I want to see them next to the result. I can do this by putting
a cursor at the beginning of each row, highlighting the whole thing,
and pasting. I also hit & to line up the pasted selections. sensors size interval
14 100 1 14 100 1
14 100 30 14 100 30
14 100 60 14 100 60
14 500 1 14 500 1
14 500 30 14 500 30
14 500 60 14 500 60
Now, because I don't want to have to think about the stack too hard,
I put 1440 (minutes per day) and 60 (seconds per minute) in before
the interval column. sensors size interval
14 100 1 14 100 1440 60 1
14 100 30 14 100 1440 60 30
14 100 60 14 100 1440 60 60
14 500 1 14 500 1440 60 1
14 500 30 14 500 1440 60 30
14 500 60 14 500 1440 60 60
Then I add my operations. And keep in mind I'm still using multiple
cursors, so all this stuff is just getting typed one time. sensors size interval
14 100 1 14 100 * 1440 * 60 * 1 / p
14 100 30 14 100 * 1440 * 60 * 30 / p
14 100 60 14 100 * 1440 * 60 * 60 / p
14 500 1 14 500 * 1440 * 60 * 1 / p
14 500 30 14 500 * 1440 * 60 * 30 / p
14 500 60 14 500 * 1440 * 60 * 60 / p
Now each line has a little dc program on it, like 14 500 * 1440 *
60 * 60 / p.I then highlight the back half of each row (again, still working
with the same set of cursors the whole time, it takes way longer to
explain this than it does to actually do it.) I type | dc
and each of my selections gets run through dc. The result is: sensors size interval
14 100 1 120960000
14 100 30 4032000
14 100 60 2016000
14 500 1 604800000
14 500 30 20160000
14 500 60 10080000
That's not super readable, so I cursor over three times (multiselection
is still active!) and insert commas, and then I do it again: sensors size interval
14 100 1 120,960,000
14 100 30 4,032,000
14 100 60 2,016,000
14 500 1 604,800,000
14 500 30 20,160,000
14 500 60 10,080,000
The result is I've done a quick back-of-the-envelope calculation on
how much data I need to handle in each scenario. |