试试这个:
//input
def allproiList = [[1, 2], [3, 4], [4, 5, 7, 8], [2, 5, 6]]
//transform to Set
Set numsOnly = allproiList.flatten() as Set
//or if you just need List of uniq elements, you could do
//List numsOnly == allproiList.flatten().unique()
//check result
assert numsOnly.sort() == [1, 2, 3, 4, 5, 6, 7, 8]
Run Code Online (Sandbox Code Playgroud)