list = {1, 2, 3} pairs = ["#{i}-#{j}" for i in *list when i % 2 == 1 for j in *list when j > i] print table.concat pairs, ","