Skip to content

Instantly share code, notes, and snippets.

View rspeer's full-sized avatar

Elia Robyn Lake (Robyn Speer) rspeer

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rspeer
rspeer / countmerge.awk
Last active June 20, 2018 00:30
Given a sorted file where each line is a key and a count, merge adjacent lines with the same key by adding their counts.
# Given a tab-separated, sorted file where each line is a key and a count,
# merge adjacent lines with the same key by adding their counts.
BEGIN {
# Initialize the current count.
# We use the empty string as a sentinel value, indicating that we haven't
# seen a key yet. We won't output a total for the empty string.
key = ""
count = 0
}
function _init()
-- tiles to move per frame
-- don't make this more than 1
fstep = 1/8
-- step counter
-- it can overflow, that's fine
step = 0
trailpos = 0