-
Hi, I am trying to combine a channel with itself to get all possible meaningful comparisons. Should be something like this: cheers = Channel.from 'Bonjour', 'Ciao', 'Hello', 'Hola'
cheers.into{cheers_a; cheers_b}
cheers_a.combine(cheers_b).set{cheers_comb}
// remove self-self
cheers_comb.filter{ it[0] != it[1] }.set{cheers_comb2}
cheers_comb2.view() which returns something like this: [Ciao, Bonjour]
[Hello, Bonjour]
[Hola, Bonjour]
[Bonjour, Ciao]
[Hello, Ciao]
[Hola, Ciao]
[Bonjour, Hello]
[Ciao, Hello]
[Hola, Hello]
[Bonjour, Hola]
[Ciao, Hola]
[Hello, Hola] However, I would also like to remove the pairs which are already repeated. Meaning, from Is there a way to do this somehow? Or could anyone guide me in how would be a nice way to approach it? Much appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Okay, I think this seems to be working but I am not sure how to scale it for a more complex channel. cheers_comb.filter{ it[0] != it[1] }
.map{it = it.sort()}
.unique()
.set{cheers_comb2} |
Beta Was this translation helpful? Give feedback.
-
You could add a closure to sort to pick only the feature of each 'cheer' to sort on, but branch might be clearer code.
|
Beta Was this translation helpful? Give feedback.
Okay, I think this seems to be working but I am not sure how to scale it for a more complex channel.