roadie has quit [Quit: ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.0.92)]
TheCatCollective is now known as CalculusCats
tomtmym has joined #ruby
tomtmym has joined #ruby
tomtmym has quit [Changing host]
Guest11 has joined #ruby
Guest11 has quit [Client Quit]
desnudopenguino1 has joined #ruby
desnudopenguino has quit [Ping timeout: 245 seconds]
desnudopenguino1 is now known as desnudopenguino
con3 has quit [Server closed connection]
roshanavand_ has quit [Ping timeout: 245 seconds]
CalculusCats is now known as TheCatCollective
con3 has joined #ruby
crespire has quit [Remote host closed the connection]
crespire has joined #ruby
roshanavand_ has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dviola has joined #ruby
caedmon has joined #ruby
caedmon has quit [Ping timeout: 264 seconds]
caedmon has joined #ruby
xanadu[m] has joined #ruby
caedmon has quit [Ping timeout: 250 seconds]
keypresser86 has joined #ruby
roadie has joined #ruby
juuh42dias has quit [Server closed connection]
juuh42dias has joined #ruby
Linux_Kerio has joined #ruby
roshanavand_ has quit [Ping timeout: 245 seconds]
keypresser86 has quit [Ping timeout: 246 seconds]
petru has quit [Server closed connection]
petru has joined #ruby
roshanavand_ has joined #ruby
hsiktas[m] has quit [Server closed connection]
dviola has quit [Remote host closed the connection]
dviola has joined #ruby
roshanavand_ has quit [Ping timeout: 264 seconds]
<isene>
I could need some intelligence; `a = [[1,2,"a,b,c",3],[4,5,"a,d,e",6],[7,8,"d,f,g",9],[1,4,"b,c,h",9]]` and `b = ["a","c"]` . I want to return only those elements of `a` (`a[2]`) that matches the elements of `b`. I.e. the first record ([1,2,"a,b,c",3],[4,5,"a,d,e",6]) is a match, but the third record ([7,8,"d,f,g",9]) is not a match. The full match would be;
weyhmueller_ has quit [Read error: Connection reset by peer]
weyhmueller has joined #ruby
jumpy has joined #ruby
<leftylink>
"only those elements of `a` that match some condition" is Enumerable#select any day of the week (AKA Enumerable#filter)
<leftylink>
and in this case, the condition here can be expressed in a few ways. 1) Enumerable#any? and Array#include?
hightower2 has quit [Ping timeout: 246 seconds]
<leftylink>
2) Array#& (or Array#intersection) and Array#empty?
<leftylink>
3) Array#intersect?
<leftylink>
oh but it needs to handle partial string matches, so 2) and 3) are right out the window
<leftylink>
it has to be 1) but actually it becomes an Enumerable#any? containing an Enumerable#any? containing a String#include?
chalet87 has joined #ruby
jumpy has quit [Ping timeout: 250 seconds]
Liothen_ is now known as Lioithen
Lioithen is now known as Liothen
<leftylink>
I apologise for initially giving wrong solutions as I had initially missed the details of the "is a match" condition
<leftylink>
solutions 2) and 3) however might still be considered though, by splitting the strings inside each element of `a`. whether that split is done 1) ahead of time and stored or 2) only temporarily, during the select will depend on other constraints.
<isene>
I was thinking a.map! as I would want to modify `a` to include only those that matches any elemnt of `b`...
<leftylink>
that's a select! then, not a map!
<isene>
OK. But this is a nesting thingie and I'm not quite sure how to nest this...