scala - Passing a function foreach key of an Array -


i have array :

val pairs: array[(int, ((vertexid, seq[int]), int))]  

which generates output :

(11,((11,arrayseq(2, 5, 4, 5)),1)) (11,((12,arrayseq(7, 7, 8, 2)),1)) (11,((13,arrayseq(5, 9, 8, 7)),1)) (1,((1,arrayseq(1, 2, 3, 4)),1)) (1,((4,arrayseq(1, 5, 1, 1)),1)) 

i want build graph each pairs._1. means example have same id ( pairs._1 ) construct graph together. thinking passing function of graph construction every id. how can ?

you're looking groupby function followed mapvalues process each group.

pairs groupby {_._1} mapvalues { groupofpairs => dosomething(groupofpairs) } 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -