<izaakf>
havenwood: I really appreciate it but the rest of my code is in ruby, are you suggesting I create perms in crystal then import them back into my code?
<havenwood>
izaakf: I'm not sure why you're doing what you're doing. Say more?
<havenwood>
On my machine with ten unique chars it's several times faster than the straightforward Crystal implementation and about twenty times faster than your Ruby example. So if you want speed it's one way.
cgibsonmm has quit [Remote host closed the connection]
nankyokusei has joined #ruby
enyo has joined #ruby
<havenwood>
izaakf: What's the point of the exercise?
<havenwood>
izaakf: You can write a Crystal extensions for Ruby gems if you want to use it in Ruby.
<havenwood>
izaakf: The shovel operator is defined as an instance method on many classes.
braincrash has quit [Ping timeout: 268 seconds]
<izaakf>
havenwood: it wont work for me when I try run code containing that
<izaakf>
havenwood: I get this in `<<': no implicit conversion of String into Integer (TypeError)
braincrash has joined #ruby
jshjsh has quit [Ping timeout: 258 seconds]
LoneHerm_ has joined #ruby
<havenwood>
izaakf: My advise would be to remove unnecessary contortions from your code. Why are you grouping by the first character at all?
LoneHerm_ has quit [Ping timeout: 268 seconds]
<izaakf>
to improve search times for words
<havenwood>
izaakf: First do it in the most straightforward and simplest manner you can come up with. Then simplify that further. Use that as your baseline.
perniciouscaffei has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
braincrash has quit [Ping timeout: 248 seconds]
<havenwood>
izaakf: i think you could really simplify the #anagram method
houhouli_ has quit [Remote host closed the connection]
<izaakf>
havenwood: I am aware but I'm a shitty programmer
houhoulis has joined #ruby
<havenwood>
izaakf: having it work at all is a good start! as they say, "red, green, refactor"
enilsen16 has joined #ruby
<izaakf>
havenwood: does .group_by(&:chr) slow this process down by much?
<havenwood>
izaakf: yes, it does
<havenwood>
izaakf: I'd suggest avoiding monkeypatching core classes like String. If you want to do that sort of thing use a refinement. but you might want to define your own class here.
hutch34 has joined #ruby
bronson has joined #ruby
<izaakf>
havenwood: what's wrong with monkeypatching core classes? Sorry if it's a dumb question
houhoulis has quit [Ping timeout: 260 seconds]
<izaakf>
havenwood: and what exactly does refinement do?
<havenwood>
izaakf: The scope of monkeypatched changes is global. So if you define Array#permutation? and a gem does as well they stomp on each other.
DLSteve has quit [Quit: All rise, the honorable DLSteve has left the channel.]
<havenwood>
izaakf: Or you can just make your own module or class and not impact core classes at all.
bronson has quit [Ping timeout: 248 seconds]
<izaakf>
havenwood: if I create a new class is it possible to be able to call the methods like I am now?
<izaakf>
like word.is_palindrome?
<havenwood>
izaakf: If you don't have any internal state to track and you just have pure functions then use a module. If there's more than one instance of state use a class. If there's just one instance of state mixin Singleton.
perniciouscaffei has joined #ruby
alan_w has joined #ruby
braincrash has joined #ruby
symm- has joined #ruby
deank has quit [Ping timeout: 265 seconds]
izaakf has quit [Quit: Page closed]
oaklndr1 has joined #ruby
porfa has joined #ruby
montanonic has quit [Ping timeout: 258 seconds]
polysics has joined #ruby
braincrash has quit [Ping timeout: 245 seconds]
mostlybadfly has joined #ruby
mim1k|wo1k has joined #ruby
jallen123 has quit [Remote host closed the connection]
arescorpio has quit [Quit: Leaving.]
mim1k|work has quit [Ping timeout: 268 seconds]
hotpancakes has joined #ruby
montanonic has joined #ruby
enilsen16 has quit [Quit: enilsen16]
hotpancakes has quit [Ping timeout: 240 seconds]
meadmoon has quit [Quit: I am functioning within established parameters.]
braincrash has joined #ruby
brendan- has joined #ruby
charliesome has joined #ruby
harai has quit [Ping timeout: 260 seconds]
cgibsonmm has joined #ruby
cgibsonmm has quit [Client Quit]
enyo has joined #ruby
gix has quit [Ping timeout: 246 seconds]
optiz0r has joined #ruby
gix has joined #ruby
enyo has quit [Ping timeout: 258 seconds]
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bronson has joined #ruby
charliesome has joined #ruby
bronson has quit [Ping timeout: 245 seconds]
JoshS has joined #ruby
sarbs has quit [Read error: Connection reset by peer]
brendan- has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
reaVer has quit [Remote host closed the connection]
sarbs has joined #ruby
nankyokusei has joined #ruby
braincrash has quit [Ping timeout: 258 seconds]
houhoulis has joined #ruby
harai has joined #ruby
nankyokusei has quit [Ping timeout: 245 seconds]
d^sh_ has quit [Ping timeout: 256 seconds]
anuxivm has left #ruby [#ruby]
biox has quit [Quit: brb servers are ded]
biox has joined #ruby
d^sh has joined #ruby
sarbs has quit [Read error: Connection reset by peer]
sarbs has joined #ruby
braincrash has joined #ruby
symm- has quit [Quit: Leaving...]
twistedpixels_ has joined #ruby
hotpancakes has joined #ruby
c355e3b has quit [Quit: Connection closed for inactivity]
testuser1 has joined #ruby
ruby-lang620 has joined #ruby
<ruby-lang620>
can anyone give me some explanation on this calculation thing
eizua has quit [Remote host closed the connection]
DoubleMalt has joined #ruby
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
nankyokusei has quit [Ping timeout: 258 seconds]
hutch34 has joined #ruby
<soahccc>
I can workaround my problem but is there a #reject! like method that return the _removed_ entries? It returns the one it keeps but I already have them in the original array :/
al2o3-cr_ has joined #ruby
aryaching has joined #ruby
aries_liuxueyang has joined #ruby
al2o3-cr has quit [Ping timeout: 268 seconds]
<toretore>
there is not
Kug3lis has joined #ruby
Kug3lis has quit [Client Quit]
jallen123 has joined #ruby
aries_liuxueyang has quit [Ping timeout: 260 seconds]
jcao219 has joined #ruby
LoneHermit has joined #ruby
jallen123 has quit [Remote host closed the connection]
hotpancakes has joined #ruby
jallen123 has joined #ruby
Sammichmaker has quit [Ping timeout: 246 seconds]
<soahccc>
toretore: I just partitioned the array and replaced the old one. Guess that is clean enough :)
LoneHermit has quit [Ping timeout: 252 seconds]
jallen123 has quit [Ping timeout: 258 seconds]
Sammichmaker has joined #ruby
iogf has joined #ruby
hotpancakes has quit [Ping timeout: 258 seconds]
enyo has joined #ruby
rcs_ has joined #ruby
<rcs_>
Hello.Can anyone of you tell me how to install metasploit on ubuntu...
enyo has quit [Ping timeout: 246 seconds]
yardenbar has quit [Ping timeout: 258 seconds]
cibs has quit [Ping timeout: 268 seconds]
cibs has joined #ruby
ishahnaz has quit []
luckyruby has joined #ruby
houhoulis has joined #ruby
Kug3lis_off is now known as Kug3lis
nadir has joined #ruby
pilne has joined #ruby
milardovich has quit [Remote host closed the connection]
milardovich has joined #ruby
aries_liuxueyang has joined #ruby
xen0fon has quit [Quit: xen0fon]
milardovich has quit [Ping timeout: 252 seconds]
DLSteve has joined #ruby
rcs_ has quit [Ping timeout: 256 seconds]
milardovich has joined #ruby
raeoks has joined #ruby
nikivi has quit [Quit: zzz]
Sanctus has quit [Remote host closed the connection]
saneax is now known as saneax-_-|AFK
milardovich has quit [Ping timeout: 248 seconds]
symm- has joined #ruby
bronson has joined #ruby
symm- has quit [Client Quit]
milardovich has joined #ruby
jallen123 has joined #ruby
jmignault has joined #ruby
bronson has quit [Ping timeout: 258 seconds]
symm- has joined #ruby
milardovich has quit [Remote host closed the connection]
milardovich has joined #ruby
jcao219 has quit [Ping timeout: 258 seconds]
saneax-_-|AFK is now known as saneax
jallen123 has quit [Remote host closed the connection]
Pupeno_ has quit [Remote host closed the connection]
jmignault has quit [Ping timeout: 264 seconds]
jmignault has joined #ruby
hutch34 has joined #ruby
sparab97 has joined #ruby
raeoks has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<sparab97>
I am new to the open source community and have decent knowledge about ruby and rails. Could someone please guide me as what steps should I follow in order to have a chance to be selected for gsoc 17 with ruby. Thank you
sparab97 has quit [Client Quit]
sparab97 has joined #ruby
hotpancakes has joined #ruby
ruid has joined #ruby
ruid has joined #ruby
ruid has quit [Changing host]
jhack has joined #ruby
jhack has quit [Client Quit]
jenrzzz has joined #ruby
aries_liuxueyang has quit [Ping timeout: 260 seconds]
tekeli-li has joined #ruby
Fernando-Basso has joined #ruby
gizmore has joined #ruby
hotpancakes has quit [Ping timeout: 245 seconds]
jenrzzz has quit [Ping timeout: 258 seconds]
aries_liuxueyang has joined #ruby
doublemalt_ has joined #ruby
conta has quit [Ping timeout: 258 seconds]
dviola has joined #ruby
d0nn1e has quit [Ping timeout: 265 seconds]
nikivi has joined #ruby
SpiffTR has joined #ruby
Fernando-Basso has quit [Quit: WeeChat 1.6]
Pupeno has joined #ruby
d0nn1e has joined #ruby
DoubleMalt has quit [Ping timeout: 265 seconds]
milardovich has quit [Read error: Connection reset by peer]
milardovich has joined #ruby
Pupeno has quit [Ping timeout: 248 seconds]
saneax is now known as saneax-_-|AFK
bronson has joined #ruby
nankyokusei has joined #ruby
milardovich has quit []
bronson has quit [Ping timeout: 268 seconds]
luckyruby has quit [Quit: Leaving...]
SpiffTR has quit [Quit: Leaving.]
nankyokusei has quit [Ping timeout: 256 seconds]
dminuoso has quit [Ping timeout: 245 seconds]
jallen123 has joined #ruby
LoneHerm_ has joined #ruby
reverberations has joined #ruby
dminuoso has joined #ruby
vuoto has joined #ruby
LoneHerm_ has quit [Ping timeout: 264 seconds]
enilsen16 has joined #ruby
aries_liuxueyang has quit [Quit: No Ping reply in 180 seconds.]
Channel6 has joined #ruby
Ishido has joined #ruby
vuoto has quit [Quit: Lost terminal]
aries_liuxueyang has joined #ruby
enyo has joined #ruby
SpiffTR has joined #ruby
bronson has joined #ruby
conta has joined #ruby
aries_liuxueyang has quit [Ping timeout: 252 seconds]
enyo has quit [Ping timeout: 264 seconds]
aries_liuxueyang has joined #ruby
izaakf has joined #ruby
xen0fon has joined #ruby
Olipro_ has joined #ruby
Kaze_FX has joined #ruby
Kaze_FX has quit [Client Quit]
tvon has joined #ruby
Olipro has quit [Ping timeout: 260 seconds]
Olipro_ is now known as Olipro
teclator has quit [Ping timeout: 258 seconds]
teclator_ has joined #ruby
Azure has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<izaakf>
hey
Kaze_FX has joined #ruby
meadmoon has joined #ruby
hotpancakes has joined #ruby
SpiffTR has quit [Quit: Leaving.]
frozengeek__ has quit [Read error: Connection reset by peer]
tk__ has quit [Quit: ばいばい]
<havenwood>
izaakf: hi
hotpancakes has quit [Ping timeout: 258 seconds]
hotpancakes has joined #ruby
hotpancakes has quit [Remote host closed the connection]
frozengeek__ has joined #ruby
jallen123 has quit [Ping timeout: 258 seconds]
<izaakf>
havenwood: Before I try to do it for permutations. Do you think Cartesian products would help generate permutations a lot quicker
<izaakf>
?
sparab97 has quit [Ping timeout: 260 seconds]
nikivi has quit [Quit: zzz]
nikivi has joined #ruby
hotpancakes has joined #ruby
hotpancakes has quit [Remote host closed the connection]
nadir has quit [Quit: Connection closed for inactivity]
Mon_Ouie has joined #ruby
gheegh has quit [Ping timeout: 258 seconds]
hahuang61 has joined #ruby
jshjsh has quit [Ping timeout: 265 seconds]
chadhs has joined #ruby
<izaakf>
is it possible to do something like this in ruby? (x -= 1)*=-1
aries_liuxueyang has quit [Ping timeout: 260 seconds]
chadhs has quit [Client Quit]
<tobiasvl>
izaakf: it's not possible to do exactly that, but to answer whether you can do something "like" that I need to know what you want to achieve
<matthewd>
izaakf: Not like that
aries_liuxueyang has joined #ruby
<izaakf>
just toggling a variable between 1 and 0
<izaakf>
so I have x -=1; x *= -1 which does what I want I was just wondering if there's a more compact way of doing it
<matthewd>
one = [0, 1].cycle; ........; one.next
<izaakf>
matthewd: is that really a better way to do what I'm trying to do? surely what I'm doing requires less memory
<tobiasvl>
izaakf: do something like matthewd suggests, but for your specific question: x = (x - 1) * -1
muelleme has quit [Ping timeout: 265 seconds]
<izaakf>
tobiasvl: I already had your suggestion, and I was trying to upgrade it. I thought x -= 1; x *= -1 would be better but maybe not
<matthewd>
If you care about memory to that degree, you're in the wrong language
<matthewd>
My real question would be why you want a toggling 0/1, though, I guess
<izaakf>
matthewd: Fair enough, maybe I worded what I was trying say incorrectly. I'm trying to say why do .cycle when it's just as easy to do subtract then multiply
<matthewd>
Ruby has a lot of higher level functionality in core & stdlib; generally the higher you go in describing the problem you're solving, the shorter your implementation can end up
<izaakf>
matthewd: Toggleboard game
<matthewd>
One describes what you want, the other describes (arcanely) how to do it
Ishido has quit [Read error: Connection reset by peer]
a1ph4g33k has joined #ruby
<matthewd>
If you're just toggling between two arbitrary values, why not true & false?
<izaakf>
matthewd: the board is an array
<izaakf>
matthewd: 0 = off 1 = on, just thought that was the most logical way to create it
duderonomy has joined #ruby
Ishido has joined #ruby
<tobiasvl>
the most logical would likely be true/false, 1 and 0 are after all magical constant values, although they're verrrrry ingrained at this point ;)
<izaakf>
tobiasvl: since it's a CLI programme, reading a table of 0's and 1's is surely easier than a table of true's and false's
Pupeno has joined #ruby
<tobiasvl>
sure, but you didn't say "easier", you said "most logical". but I have no idea what kind of program you're making, so just use whatever's best for you!
<izaakf>
tobiasvl: It's just a light's out game on the command line
<matthewd>
I'd be wary of designing the internal data structure in a way that saves you a map call when writing the UI
CloCkWeRX has quit [Ping timeout: 264 seconds]
binaryplease has joined #ruby
<izaakf>
matthewd: what do you mean?
Gasher has joined #ruby
<matthewd>
> reading a table of 0's and 1's is surely easier than a table of true's and false's
<matthewd>
"reading" == the UI
<matthewd>
No?
duderonomy has quit [Ping timeout: 240 seconds]
<izaakf>
matthewd: Yeah, the user reading it
a1ph4g33k has quit [Read error: Connection reset by peer]
<tobiasvl>
yeah don't design your internal data structure around how the data will be represented in a UI, that's bound to burn you later
hotpancakes has quit [Remote host closed the connection]
<tobiasvl>
if the only reason you're using 1 and 0 is to print it out as that, just convert it before printing it
sarbs has quit [Read error: Connection reset by peer]
<matthewd>
I'd also think more visually distinct characters ("." and "#" or something) would be superior for actual readability, but that's getting a bit off track
conta has quit [Ping timeout: 246 seconds]
ruid has quit [Ping timeout: 268 seconds]
DTZUZU2 has quit [Read error: Connection reset by peer]
hotpancakes has joined #ruby
hotpancakes has quit [Remote host closed the connection]
hotpancakes has joined #ruby
sarbs has joined #ruby
braincrash has quit [Ping timeout: 264 seconds]
electrostat has quit [Max SendQ exceeded]
electrostat has joined #ruby
djbkd has joined #ruby
hutch34 has quit [Ping timeout: 265 seconds]
DTZUZU2 has joined #ruby
enilsen16 has quit [Quit: enilsen16]
Fernando-Basso has joined #ruby
hahuang61 has quit [Ping timeout: 268 seconds]
jallen123 has joined #ruby
braincrash has joined #ruby
SpiffTR has joined #ruby
nikivi has quit [Quit: irc]
muelleme has joined #ruby
LoneHermit has joined #ruby
enilsen16 has joined #ruby
enilsen16 has quit [Client Quit]
skweek has quit [Ping timeout: 258 seconds]
LoneHermit has quit [Ping timeout: 246 seconds]
izaakf has quit [Ping timeout: 260 seconds]
nankyokusei has joined #ruby
conta has joined #ruby
enilsen16 has joined #ruby
duderonomy has joined #ruby
gigetoo has quit [Ping timeout: 258 seconds]
Azure has quit [Ping timeout: 264 seconds]
gigetoo has joined #ruby
mattwildig has joined #ruby
nankyokusei has quit [Ping timeout: 245 seconds]
enyo has joined #ruby
Azure has joined #ruby
Pupeno has quit [Remote host closed the connection]
<ruby[bot]>
thadtheman: pastebin.com loads slowly for most, has ads which are distracting and has terrible formatting.
benlieb has quit [Quit: benlieb]
<thadtheman>
Why does line 19 generate 500+ simultaneous processes? I thought popen waits untill the process is done.
lolmaus_ has joined #ruby
<chrisseaton>
thadtheman: IO.popen is non-blocking - the Ruby process continues to run as the new process does. However it may block later on if you connect the standard IO streams of the child process to something which needs to be drained.
<thadtheman>
chrisseaton: can you clarify the however? What do you mean by connect?
<chrisseaton>
thadtheman: IO.popen starts a process and gives you an IO object where when you read and write you do so from the process. I'm not entirely sure of the semantics, but I think you are responsible for reading from the process promptly. If it has written a lot and you aren't reading, I think the kernel will pause it until you have read more. The kernel can't
<chrisseaton>
infinitely buffer the output of the child process forever, so at some point it needs to block.
hahuang61 has joined #ruby
<chrisseaton>
thadtheman: It's similar to Unix pipes, if you're familiar with them.
al2o3-cr has joined #ruby
benlieb has joined #ruby
benlieb has quit [Client Quit]
mrwn has joined #ruby
porfa has quit [Quit: porfa]
hahuang61 has quit [Ping timeout: 246 seconds]
porfa has joined #ruby
al2o3-cr_ has quit [Ping timeout: 248 seconds]
<wnd>
thadtheman, it is probably not the point here, but I just had to. dpkg --get-selections | sed '/deinstall/d; s/\s.*//' | xargs apt-cache show | sed '/^Source: /!d; s/[^ ]* //; s/ .*//' | sort -u | xargs apt-get source (which also fails vcs-sources, and may misbehave with versioned sources)
<wnd>
at the very least it's probably a whole lot faster
electrostat has quit [Quit: uwotm8]
harai has joined #ruby
lightstalker has quit [Remote host closed the connection]
electrostat has joined #ruby
hotpancakes has quit [Remote host closed the connection]
sepp2k has quit [Disconnected by services]
sepp2k1 has joined #ruby
foption has quit [Remote host closed the connection]
sepp2k has joined #ruby
lightstalker has joined #ruby
jshjsh has quit [Ping timeout: 268 seconds]
sepp2k1 has quit [Ping timeout: 260 seconds]
nowhere_man has quit [Quit: Konversation terminated!]
zipace has quit [Quit: Leaving]
nowhere_man has joined #ruby
hotpancakes has joined #ruby
hutch34 has joined #ruby
arthurbalfredo has quit [Quit: Connection closed for inactivity]
Azure has joined #ruby
hutch34 has quit [Remote host closed the connection]
teclator_ has quit [Quit: No Ping reply in 180 seconds.]
meadmoon has quit [Quit: I am functioning within established parameters.]
teclator has joined #ruby
hutch34 has joined #ruby
mark[oz] has joined #ruby
<solidsnack>
When building a native gem, how does Ruby which build products to include in the resultant installation?
jmignault has joined #ruby
teclator has quit [Quit: No Ping reply in 180 seconds.]
<chrisseaton>
solidsnack: Do you mean which .so files and things?
<solidsnack>
Right.
teclator has joined #ruby
<chrisseaton>
solidsnack: Do you know about the extconf.rb file? That configures it, but I think there's quite a bit of convention-over-configuration in this part of the system.
<solidsnack>
So as far as I can tell, people use that script to generate a Makefile.
<solidsnack>
Then further magic calls the Makefile.
<solidsnack>
Maybe the name of the extension is used to set some target in the Makefile?
<chrisseaton>
It's not too much magic - it's as you described - run extconf.rb, and then run make.
jmignault has quit [Ping timeout: 265 seconds]
<chrisseaton>
extconf.rb does most things based on the values in RbConfig
<solidsnack>
I see.
<solidsnack>
So maybe RbConfig has some defaults like, if the extension is called y, try to copy liby.dylib on Mac, liby.so on Linux, y.dll on Windows and so forth.
LoneHerm_ has joined #ruby
Anonymoose2 has joined #ruby
<chrisseaton>
solidsnack: Yes that's exactly it.
<chrisseaton>
solidsnack: For example, OBJEXT, DLEXT, CPPFLAGS, LIBEXT are all configuration options in there.
toretore has joined #ruby
izaakf has joined #ruby
xen0fon has joined #ruby
reverberations has quit [Ping timeout: 258 seconds]
binaryplease has joined #ruby
LoneHerm_ has quit [Ping timeout: 264 seconds]
Ishido has quit [Quit: Roads? Where We're Going We Don't Need Roads.]
roamingdog has joined #ruby
teclator has quit [Quit: No Ping reply in 180 seconds.]
hotpancakes has quit [Remote host closed the connection]
xen0fon has quit [Client Quit]
montanonic has joined #ruby
hotpancakes has joined #ruby
porfa has quit [Quit: porfa]
teclator has joined #ruby
<solidsnack>
Hmm, okay.
<solidsnack>
So what I have is a Ruby file that talks to a Rust library.
<solidsnack>
It uses FFI to do so.
<solidsnack>
So I don't really need to build an actual extension.
<chrisseaton>
solidsnack: You just need to build the standalone Ruby library.
<solidsnack>
Oh?
<chrisseaton>
solidsnack: I mean - that's just what you need to do, I believe?
<solidsnack>
Well, I think I need to make building the Rust code part of installing the Gem.
<chrisseaton>
solidsnack: Maybe look at Nokogiri, which builds libxml itself I believe. However I'm sure that's very complicated.
<solidsnack>
Ah. They might have a custom Makefile.
<chrisseaton>
solidsnack: Well, hopefully just a couple of custom commands in extconf.rb
montanonic has quit [Ping timeout: 252 seconds]
hotpancakes has quit [Ping timeout: 245 seconds]
<chrisseaton>
solidsnack: There must be simpler examples of what you want to do than Nokogiri, but I'm afraid I'm not sure what they are.
benlieb has joined #ruby
<chrisseaton>
solidsnack: FFI is normally used to access system libraries that you manually install using a system package manager. But your usage is also sensible.
teclator has quit [Quit: No Ping reply in 180 seconds.]
Azure has quit [Ping timeout: 264 seconds]
<solidsnack>
Trying to generate all the Ruby extension C stuff seemed like trouble :)
teclator has joined #ruby
mrwn has quit [Remote host closed the connection]
<chrisseaton>
solidsnack: The FFI is also more compatible with JRuby and Rubinius.
teclator has quit [Client Quit]
bmurt has joined #ruby
teclator has joined #ruby
Azure has joined #ruby
porfa has joined #ruby
Fernando-Basso has quit [Quit: WeeChat 1.6]
djbkd has joined #ruby
balazs has quit [Read error: Connection reset by peer]
flying has quit []
hotpancakes has joined #ruby
bronson has quit [Remote host closed the connection]
grug has quit [Ping timeout: 258 seconds]
jhack has joined #ruby
_sfiguser has joined #ruby
porfa has quit [Quit: porfa]
sarlalian has quit [Ping timeout: 258 seconds]
teclator has quit [Quit: No Ping reply in 180 seconds.]
enyo has joined #ruby
teclator has joined #ruby
jhack has quit [Client Quit]
ledestin has joined #ruby
ruid has joined #ruby
ruid has quit [Changing host]
ruid has joined #ruby
tmtwd has joined #ruby
grug has joined #ruby
enyo has quit [Ping timeout: 258 seconds]
sarlalian has joined #ruby
Azure has quit [Ping timeout: 246 seconds]
<izaakf>
Hi I'm trying to group words by chars with this code self.group_by(&:chars)
<izaakf>
is there anyway to do this and get words with the same letters grouped together
<Papierkorb>
izaakf: could you give an example input with the expected output?
<izaakf>
e.g to {["e", "r", "a" => ["era", "are"]}
<izaakf>
for that example if input is era
<izaakf>
e.g to {["e", "r", "a"] => ["era", "are"]}*
<apeiros>
izaakf: sort the letters
teclator has quit [Quit: No Ping reply in 180 seconds.]
maloik48 has quit [Remote host closed the connection]
<Papierkorb>
>> %w[era are foo bar].map{|word| [ word.chars.to_a.sort, word ]}.reduce(Hash.new{|h, k| h[k] = []}){|h, (k, v)| h[k] << v; h}