Skip to content

Commit

Permalink
docs: add fold
Browse files Browse the repository at this point in the history
  • Loading branch information
farbodsalimi committed Feb 2, 2023
1 parent f56a9cc commit 1aa0e8f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Goulash provides a bunch of useful functional programming helpers leveraging Go
- [Contains](#contains)
- [Difference](#difference)
- [Filter](#filter)
- [Fold](#fold)
- [ForEach](#foreach)
- [GroupBy](#groupby)
- [Intersection](#intersection)
Expand Down Expand Up @@ -145,6 +146,15 @@ filtered := __.Filter([]int{1, 2, 3, 4, 5, 6}, func(n int) bool {
fmt.Println(filtered) // [1 3 5]
```

### Fold

```go
folded := __.Fold([]int{1, 2, 3}, 0, func(a int, b int) int {
return a + b
})
fmt.Println(folded) // 6
```

### ForEach

```go
Expand Down

0 comments on commit 1aa0e8f

Please sign in to comment.