Adds DedupeStrings(input []string) []string, which returns a new slice
holding 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:
The code is in a new file, dedupe.go, rather than appended to util.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.
Sorting-based deduplication would be shorter but would lose the input order,
so this keeps a set of values seen so far instead.
make test on this branch reports one failure, TestNowUnixMicro. That test
already fails on master and is unrelated to this change: it compares a
nanosecond-precision timestamp against one that has been rounded to
microseconds.
Model: opus-5
Adds `DedupeStrings(input []string) []string`, which returns a new slice
holding 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:
- The code is in a new file, `dedupe.go`, rather than appended to `util.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.
- Sorting-based deduplication would be shorter but would lose the input order,
so this keeps a set of values seen so far instead.
- `make test` on this branch reports one failure, `TestNowUnixMicro`. That test
already fails on `master` and is unrelated to this change: it compares a
nanosecond-precision timestamp against one that has been rounded to
microseconds.
Model: opus-5
clawbot
self-assigned this 2026-09-05 05:23:45 +02:00
DedupeStrings returns a new slice holding each value once, in the order each
value first appeared, and leaves the input slice alone. Comes with a doc
comment and table-driven tests. (closes#1)
Model: opus-5
sneak
merged commit 0183d1a782 into master2026-09-05 05:46:19 +02:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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