Skip to content

Commit 2141361

Browse files
committed
Simplify README examples with type inference
1 parent 78df544 commit 2141361

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ A general purpose library offering functional helpers for Golang.
66

77
```go
88
// Find the first 5 prime numbers
9-
primes := iter.Take[int](iter.Filter[int](iter.Count(), isPrime), 5)
10-
assert.SliceEqual(t, iter.Collect[int](primes), []int{2, 3, 5, 7, 11})
9+
primes := iter.Take(iter.Filter(iter.Count(), isPrime), 5)
10+
assert.SliceEqual(t, iter.Collect(primes), []int{2, 3, 5, 7, 11})
1111
```
1212

1313
_[Read the docs.](https://pkg.go.dev/github.com/BooleanCat/go-functional)_
@@ -53,15 +53,15 @@ library.
5353
```go
5454
// All even natural numbers (2, 4, 6, 8...)
5555
isEven := func(n int) bool { return n%2 == 0 }
56-
evens := iter.Filter[int](iter.Drop[int](iter.Count(), 1), isEven)
56+
evens := iter.Filter(iter.Drop(iter.Count(), 1), isEven)
5757
```
5858

5959
```go
6060
// All non-empty lines from a file
61-
lines := iter.Exclude[string](iter.LinesString(file), filters.IsZero[string])
61+
lines := iter.Exclude(iter.LinesString(file), filters.IsZero)
6262
```
6363

6464
```go
6565
// String representations of numbers
66-
numbers := iter.Map[int, string](iter.Count(), strconv.Itoa)
66+
numbers := iter.Map(iter.Count(), strconv.Itoa)
6767
```

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/BooleanCat/go-functional
22

3-
go 1.18
3+
go 1.20

0 commit comments

Comments
 (0)