Created
March 26, 2018 08:06
-
-
Save danrl/31f20f003862a1b6da210eb3307358b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func joiner(metadata, setIDs <-chan *line, out chan<- *line) { | |
defer close(out) // close channel on return | |
si := &line{} | |
for md := range metadata { | |
sep := "," | |
// add matching strength set (if left over from previous iteration) | |
if si.id == md.id { | |
md.restOfLine += sep + si.restOfLine | |
sep = " " | |
} | |
// look for matching strength sets | |
for si = range setIDs { | |
// add all strength sets with matching IDs | |
if si.id == md.id { | |
md.restOfLine += sep + si.restOfLine | |
sep = " " | |
} else if si.id > md.id { | |
break | |
} | |
// skip all strength sets with lower IDs | |
} | |
// send the augmented line into the channel | |
out <- md | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment