rueban[鲁班]

A toolkit for slicing map and other data processing

Array[slice]

Chunk

array.chunk(['a', 'b', 'c', 'd', 'e'], 2)
// ==> [['a', 'b'],['c', 'd']['e']]

Diffrernce

Diffrernce([]int{1,2,3,4,5}, []int{2, 3},
func(i int) int {
	return i
})

// ==> []int{1,4,5}

Drop

array.Drop(['a', 'b', 'c', 'd', 'e'], 2,3)
// ==> ['a', 'b', 'e']

Fill

array.Fill(['a', 'b', 'c', 'd', 'e'],'d', 1,5)
// ==> ['e','d','d','d','d']

Find

array.Find(['a', 'b', 'c', 'd', 'e'], func(v string) bool {
	return v != "c"
})

// ==> ['a', 'b', 'd', 'e'], true, [0, 1, 3, 4]

FindFirst

array.Find(['a', 'b', 'c', 'd', 'e'], func(v string) bool {
	return v != "c"
})

// ==> 'a', true, 0

GitHub

View Github