godash icon indicating copy to clipboard operation
godash copied to clipboard

Add Flatten function

Open aswinkarthik opened this issue 5 years ago • 4 comments

API:

array1 := []int{1,2,3}
array2 := []int{4,5,6}
array3 := []int{7,8,9}
var ouput []int

godash.Flatten(&output, array1, array2, array3)

// output should be []int{1,2,3,4,5,6,7,8,9}

aswinkarthik avatar Oct 12 '19 11:10 aswinkarthik

Flatten can easily be implemented using consecutive append calls. I am having doubts if flatten will help @arunvelsriram

aswinkarthik avatar Oct 13 '19 16:10 aswinkarthik

I think it's okay since lodash is providing it even though it could be achieved by a series of concat().

a = [1,2,3]
b = [4,5,6]
c = [7, 8, 9]
d = a.concat(b).concat(c) 
// d = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]

arunvelsriram avatar Oct 13 '19 16:10 arunvelsriram

@arunvelsriram @aswinkarthik I can take this up.

sharath2106 avatar Oct 14 '19 11:10 sharath2106

Sure go ahead.

@aswinkarthik could you share the deep flatten idea we discussed offline?

arunvelsriram avatar Oct 15 '19 17:10 arunvelsriram