Skip to content

Commit ddc2c53

Browse files
Merge pull request #135 from logic-building/methodchain
Methodchain
2 parents e8a355c + 11fc130 commit ddc2c53

File tree

375 files changed

+13829
-858
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

375 files changed

+13829
-858
lines changed

.circleci/config.yml

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ jobs: # basic units of work in a run
33
build: # runs not using Workflows must have a `build` job as entry point
44
docker: # run the steps with Docker
55
# CircleCI Go images available at: https://hub.docker.com/r/circleci/golang/
6-
- image: circleci/golang:1.11 #
6+
- image: circleci/golang:1.15 #
77

88
# directory where steps are run. Path must conform to the Go Workspace requirements
99
working_directory: /go/src/github.com/logic-building/functional-go/

.gitignore

100644100755
File mode changed.

AUTHORS

100644100755
File mode changed.

LICENSE

100644100755
File mode changed.

README.md

100644100755
Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ go install github.com/logic-building/functional-go/gofp
2121
```toml
2222
[[constraint]]
2323
name = "github.com/logic-building/functional-go"
24-
version = "8.13.1"
24+
version = "8.14.0"
2525
```
2626

2727
### Quick Start
@@ -36,7 +36,7 @@ func square(num int) int {
3636
}
3737

3838
```
39-
#### Four variants of function. 1 is given above and 3 are given below
39+
#### Four variants of the function. 1 is given above and 3 are given below
4040
##### MapInt, MapIntPtr, MapIntErr, MapIntPtrErr
4141
### MapIntPtr
4242
```go
@@ -341,6 +341,27 @@ Note:
341341
26. Union : Return a set that is the union of the input sets. Repeated value within list(argument) will be ignored
342342
27. Union<struct>By<Field>
343343
```
344+
345+
### Method chain functionality for Basic type as well as struct -
346+
#### Map, Filter, Sort, Distinct, Reverse, DropWhile, TakeWhile, Remove
347+
#### Examples
348+
```go
349+
// Use MakeIntSlicePtr for pointer version
350+
r := fp.MakeIntSlice([]int{3, 2, 1}...).
351+
Filter(odd).
352+
Map(square).
353+
Sort()
354+
fmt.Println(r) // [1 9]
355+
356+
func odd (num int) bool {
357+
return num % 2 != 0
358+
}
359+
func square(num int) int {
360+
return num * num
361+
}
362+
363+
```
364+
344365
### Contains functions
345366
```
346367
Takes list as argument and returns Distinct list. Returns empty list if 2nd parameter is empty or nil

fp/benchmark_test.go

100644100755
File mode changed.

fp/bool.go

100644100755
File mode changed.

fp/bool_test.go

100644100755
File mode changed.

fp/dedupe.go

100644100755
File mode changed.

fp/dedupe_test.go

100644100755
File mode changed.

0 commit comments

Comments
 (0)