Skip to content

Commit 1c3c8f2

Browse files
Merge pull request #109 from logic-building/Take<Type>
Added function Take<Type> to return 1st n items
2 parents 42802b2 + af3ace0 commit 1c3c8f2

File tree

15 files changed

+1500
-18
lines changed

15 files changed

+1500
-18
lines changed

fp/filterErr.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package fp
44
// 1. Funtion: takes 1 argument of type int and returns (bool, error)
55
// 2. slice of type []int
66
//
7-
// Returns:
7+
// Returns:
88
// new filtered list and error
99
func FilterIntErr(f func(int) (bool, error), list []int) ([]int, error) {
1010
if f == nil {
@@ -27,7 +27,7 @@ func FilterIntErr(f func(int) (bool, error), list []int) ([]int, error) {
2727
// 1. Funtion: takes 1 argument of type int64 and returns (bool, error)
2828
// 2. slice of type []int64
2929
//
30-
// Returns:
30+
// Returns:
3131
// new filtered list and error
3232
func FilterInt64Err(f func(int64) (bool, error), list []int64) ([]int64, error) {
3333
if f == nil {
@@ -50,7 +50,7 @@ func FilterInt64Err(f func(int64) (bool, error), list []int64) ([]int64, error)
5050
// 1. Funtion: takes 1 argument of type int32 and returns (bool, error)
5151
// 2. slice of type []int32
5252
//
53-
// Returns:
53+
// Returns:
5454
// new filtered list and error
5555
func FilterInt32Err(f func(int32) (bool, error), list []int32) ([]int32, error) {
5656
if f == nil {
@@ -73,7 +73,7 @@ func FilterInt32Err(f func(int32) (bool, error), list []int32) ([]int32, error)
7373
// 1. Funtion: takes 1 argument of type int16 and returns (bool, error)
7474
// 2. slice of type []int16
7575
//
76-
// Returns:
76+
// Returns:
7777
// new filtered list and error
7878
func FilterInt16Err(f func(int16) (bool, error), list []int16) ([]int16, error) {
7979
if f == nil {
@@ -96,7 +96,7 @@ func FilterInt16Err(f func(int16) (bool, error), list []int16) ([]int16, error)
9696
// 1. Funtion: takes 1 argument of type int8 and returns (bool, error)
9797
// 2. slice of type []int8
9898
//
99-
// Returns:
99+
// Returns:
100100
// new filtered list and error
101101
func FilterInt8Err(f func(int8) (bool, error), list []int8) ([]int8, error) {
102102
if f == nil {
@@ -119,7 +119,7 @@ func FilterInt8Err(f func(int8) (bool, error), list []int8) ([]int8, error) {
119119
// 1. Funtion: takes 1 argument of type uint and returns (bool, error)
120120
// 2. slice of type []uint
121121
//
122-
// Returns:
122+
// Returns:
123123
// new filtered list and error
124124
func FilterUintErr(f func(uint) (bool, error), list []uint) ([]uint, error) {
125125
if f == nil {
@@ -142,7 +142,7 @@ func FilterUintErr(f func(uint) (bool, error), list []uint) ([]uint, error) {
142142
// 1. Funtion: takes 1 argument of type uint64 and returns (bool, error)
143143
// 2. slice of type []uint64
144144
//
145-
// Returns:
145+
// Returns:
146146
// new filtered list and error
147147
func FilterUint64Err(f func(uint64) (bool, error), list []uint64) ([]uint64, error) {
148148
if f == nil {
@@ -165,7 +165,7 @@ func FilterUint64Err(f func(uint64) (bool, error), list []uint64) ([]uint64, err
165165
// 1. Funtion: takes 1 argument of type uint32 and returns (bool, error)
166166
// 2. slice of type []uint32
167167
//
168-
// Returns:
168+
// Returns:
169169
// new filtered list and error
170170
func FilterUint32Err(f func(uint32) (bool, error), list []uint32) ([]uint32, error) {
171171
if f == nil {
@@ -188,7 +188,7 @@ func FilterUint32Err(f func(uint32) (bool, error), list []uint32) ([]uint32, err
188188
// 1. Funtion: takes 1 argument of type uint16 and returns (bool, error)
189189
// 2. slice of type []uint16
190190
//
191-
// Returns:
191+
// Returns:
192192
// new filtered list and error
193193
func FilterUint16Err(f func(uint16) (bool, error), list []uint16) ([]uint16, error) {
194194
if f == nil {
@@ -211,7 +211,7 @@ func FilterUint16Err(f func(uint16) (bool, error), list []uint16) ([]uint16, err
211211
// 1. Funtion: takes 1 argument of type uint8 and returns (bool, error)
212212
// 2. slice of type []uint8
213213
//
214-
// Returns:
214+
// Returns:
215215
// new filtered list and error
216216
func FilterUint8Err(f func(uint8) (bool, error), list []uint8) ([]uint8, error) {
217217
if f == nil {
@@ -234,7 +234,7 @@ func FilterUint8Err(f func(uint8) (bool, error), list []uint8) ([]uint8, error)
234234
// 1. Funtion: takes 1 argument of type string and returns (bool, error)
235235
// 2. slice of type []string
236236
//
237-
// Returns:
237+
// Returns:
238238
// new filtered list and error
239239
func FilterStrErr(f func(string) (bool, error), list []string) ([]string, error) {
240240
if f == nil {
@@ -257,7 +257,7 @@ func FilterStrErr(f func(string) (bool, error), list []string) ([]string, error)
257257
// 1. Funtion: takes 1 argument of type bool and returns (bool, error)
258258
// 2. slice of type []bool
259259
//
260-
// Returns:
260+
// Returns:
261261
// new filtered list and error
262262
func FilterBoolErr(f func(bool) (bool, error), list []bool) ([]bool, error) {
263263
if f == nil {
@@ -280,7 +280,7 @@ func FilterBoolErr(f func(bool) (bool, error), list []bool) ([]bool, error) {
280280
// 1. Funtion: takes 1 argument of type float32 and returns (bool, error)
281281
// 2. slice of type []float32
282282
//
283-
// Returns:
283+
// Returns:
284284
// new filtered list and error
285285
func FilterFloat32Err(f func(float32) (bool, error), list []float32) ([]float32, error) {
286286
if f == nil {
@@ -303,7 +303,7 @@ func FilterFloat32Err(f func(float32) (bool, error), list []float32) ([]float32,
303303
// 1. Funtion: takes 1 argument of type float64 and returns (bool, error)
304304
// 2. slice of type []float64
305305
//
306-
// Returns:
306+
// Returns:
307307
// new filtered list and error
308308
func FilterFloat64Err(f func(float64) (bool, error), list []float64) ([]float64, error) {
309309
if f == nil {

fp/filterPtrErr_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package fp
22

33
import (
4-
"errors"
4+
"errors"
55
"testing"
66
)
77

fp/sortstrs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package fp
22

33
import "sort"
4+
45
func SortStrs(list []string) []string {
56
if len(list) == 0 {
67
return []string{}

0 commit comments

Comments
 (0)