Skip to content

Commit c34413b

Browse files
committed
feat: include output for examples in README.md
1 parent 3ddf3c2 commit c34413b

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
# go-slices
77

8-
The goal in mind for this `go-slices` module is to provide basic generics to cover all the common operations a developer
9-
will typically perform on a slice.
8+
The goal in mind for this `go-slices` module is to provide basic generics to cover all the common operations a developer will typically perform on a slice.
109

1110
## Installation
1211

@@ -17,15 +16,27 @@ go get github.com/skippyza/go-slices
1716
## Examples
1817

1918
Filter even numbers
20-
2119
```golang
2220
slices.Filter([]int{1, 2, 3, 4, 5}, func(i int) bool { return i%2 == 0 })
21+
22+
// Output:
23+
// [2 4]
2324
```
2425

2526
Double all the numbers
26-
2727
```golang
2828
slices.Map([]int{8, 14, 23}, func(i int) int { return i*2 })
29+
30+
// Output:
31+
// [16 28 46]
32+
```
33+
34+
Sum all the numbers in a slice
35+
```golang
36+
slices.Reduce([]int{5, 1, 2, 2}, func(prev, cur int) int { return prev + cur }, 0)
37+
38+
// Output:
39+
// 10
2940
```
3041

3142
## Usage

0 commit comments

Comments
 (0)