Skip to content

Releases: elliotchance/pie

v2.8.0

08 Sep 17:39
4912a95
Compare
Choose a tag to compare
Added Rotate (#198)

Rotate returns slice circularly rotated by a number of positions n.
If n is positive, the slice is rotated right.
If n is negative, the slice is rotated left.

v2.7.1

07 Sep 13:49
f1ace5f
Compare
Choose a tag to compare
Shift to accept any parameter (#197)

v2.7.0

19 Jun 20:16
36b1ca2
Compare
Choose a tag to compare
Add Delete function (#194)

Delete removes elements at indices in idx from input slice, returns resulting slice.
If an index is out of bounds, skip it.

v2.6.0

08 Jun 13:24
90bf328
Compare
Choose a tag to compare
Add Zip and ZipLongest function (#193)

Zip will return a new slice containing pairs with elements from input slices.
If input slices have different length, the output slice will be truncated to
the length of the smallest input slice.

ZipLongest will return a new slice containing pairs with elements from input slices.
If input slices have diffrent length, missing elements will be padded with default values.

These are the same as zip() and itertools.zip_longest() in Python.

v2.5.2

24 Mar 17:36
a9ee294
Compare
Choose a tag to compare
perf:  New implemention for Diff() (#191)

Using set instead of nested for loops, the time complexity is reduced from O(n^2) to O(n)

v2.5.1

27 Feb 23:26
7263418
Compare
Choose a tag to compare
docs: Add doc comments to `OfSlice[T]` methods (#190)

Copy doc comments from functions to the respective OfSlice[T] methods.

Fixes #186

Co-authored-by: Kirill Morozov <6203454+kirillmorozov@users.noreply.github.com>

v2.5.0

27 Feb 15:33
42749e4
Compare
Choose a tag to compare
Add GroupBy (#189)

GroupBy groups slice elements by key returned by getKey function for each
slice element.

It returns a map in which slices of elements of original slice are matched
to keys defined by getKey function. It returns non-nil map, if empty or nil
slice is passed.

For example, if you want to group integers by their remainder from division
by 5, you can use this function as follows:

	_ = pie.GroupBy(
	    []int{23, 76, 37, 11, 23, 47},
	    func(num int) int {
	        return num % 5
	    },
	)

In above case map {1:[76, 11], 2:[37, 47], 3:[23, 23]} is returned.

Fixes #188

v2.4.0

17 Feb 18:20
4abd3ae
Compare
Choose a tag to compare
Adding Flat (#187)

Flat flattens the two-dimensional slice into one-dimensional slice.
Slices of zero-length are ignored.

Examples:

	Flat([[100], [101, 102], [102, 103]])   => [100, 101, 102, 102, 103]
	Flat([nil, [101, 102], []])             => [101, 102]

Co-authored-by: Dmytro Misik <d.misik@draftkings.com>

v2.3.0

09 Jan 16:35
9f03773
Compare
Choose a tag to compare
Chunk (#184)

Chunk splits the input and returns multi slices whose length equals
chunkLength, except for the last slice which may contain fewer elements.

Co-authored-by: morrisyang <morrisyang@tencent.com>

v2.2.0

12 Dec 16:14
ab43b76
Compare
Choose a tag to compare
Add First() and Last() in chain operation (#183)

This also improves example in the README