History

Rename Transform() back to Map()

- better discoverability - better pairing with .Filter() - shorter Fixes #45

Gregory Petrosyan committed 3 years ago

Commit cce37f21 parent 6dec3de3 files · +5 −5Browse files

Unified · Split

3 files
  1. combinators.go +2 −2
  2. combinators_external_test.go +1 −1
  3. combinators_test.go +2 −2
combinators.go+2−2
@@ -113,7 +113,7 @@ func find[V any](gen func(*T) (V, bool), t *T, tries int) V { · 112 unmodified lines
113113 panic(invalidData(fmt.Sprintf("failed to find suitable value in %d tries", tries)))
114114 }
115115
116−func Transform[U any, V any](g *Generator[U], fn func(U) V) *Generator[V] {
116+func Map[U any, V any](g *Generator[U], fn func(U) V) *Generator[V] {
117117 return newGenerator[V](&mappedGen[U, V]{
118118 g: g,
119119 fn: fn,
@@ -126,7 +126,7 @@ type mappedGen[U any, V any] struct { · 6 unmodified lines
126126 }
127127
128128 func (g *mappedGen[U, V]) String() string {
129− return fmt.Sprintf("Transform(%v, %T)", g.g, g.fn)
129+ return fmt.Sprintf("Map(%v, %T)", g.g, g.fn)
130130 }
131131
132132 func (g *mappedGen[U, V]) value(t *T) V {
combinators_external_test.go+1−1
@@ -76,7 +76,7 @@ func TestFilter(t *testing.T) { · 75 unmodified lines
7676 func TestMap(t *testing.T) {
7777 t.Parallel()
7878
79− g := Transform(Int(), strconv.Itoa)
79+ g := Map(Int(), strconv.Itoa)
8080
8181 Check(t, func(t *T) {
8282 s := g.Draw(t, "s")
combinators_test.go+2−2
@@ -16,8 +16,8 @@ type intPair struct { · 15 unmodified lines
1616 func BenchmarkHeavyChain3(b *testing.B) {
1717 t := newT(nil, newRandomBitStream(baseSeed(), false), false, nil)
1818 g1 := Custom(func(t *T) int { return Int().Draw(t, "") })
19− g2 := Transform(g1, func(i int) intPair { return intPair{i, i << 13} })
20− g3 := Transform(g2, func(p intPair) int { return p.x + p.y })
19+ g2 := Map(g1, func(i int) intPair { return intPair{i, i << 13} })
20+ g3 := Map(g2, func(p intPair) int { return p.x + p.y })
2121 b.ResetTimer()
2222
2323 for i := 0; i < b.N; i++ {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t