func block(records []Record) map[string][]Record {
blocks := map[string][]Record{}
for _, record := range records {
blocks[record.City] = append(blocks[record.City], record)
}
return blocks
}
func main() {
records := loadRecords(100)
blocks := block(records)
comparisons := 0
matchCount := 0
for _, blockRecords := range blocks {
c, m := compare(blockRecords)
comparisons += c
matchCount += m
}
fmt.Printf("made %d comparisons and found %d matches\n", comparisons, matchCount)
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter