Add DedupeStrings to remove repeated values from a string slice #2
Reference in New Issue
Block a user
Delete Branch "clawbot/util:proposal-dedupe-strings"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds
DedupeStrings(input []string) []string, which returns a new sliceholding each value once, in the order each value first appeared. The input
slice is left alone, and a nil input returns nil.
This belongs here because dropping repeated values while keeping order is
something almost every program needs at some point, and the standard library
of this module's Go version has nothing for it. It is a handful of lines that
otherwise gets copied from project to project.
Things to know:
dedupe.go, rather than appended toutil.go.Each of these proposals adds its own file so that the ten branches do not
all conflict with each other in the same place.
so this keeps a set of values seen so far instead.
make teston this branch reports one failure,TestNowUnixMicro. That testalready fails on
masterand is unrelated to this change: it compares ananosecond-precision timestamp against one that has been rounded to
microseconds.
Model: opus-5