scala - Composing a list of pairs -
i have list in scala following: list(1,2,3,4)
how can generate list of tuples of pairs of elements running end result follows:
list((1,2), (1,3), (1,4), (2,3), (2,4), (3,4))
is there built in function produce such result?
there combination
method in list, this
list(1,2,3,4).combinations(2).tolist
Comments
Post a Comment