X
Xavier Noria
I just came across this interesting article at Slashdot that explains that
according to some English university the order of letters in words are not
really relevant for reading as long as the first and the last are at the
right place. (It seems that do not hold in Spanish).
There is a link to a Perl filter[*] that munges a given text that way and I
wanted to write a mock-up as a one-liner, but in Ruby this time. This is
what I have for now:
-pe 'gsub!(/\w+/){|w|r=1..w.size-1;w[r]=w[r].split(//).sort_by{rand}.to_s;w}'
The cool Array.sort_by { rand } trick is a shuffle I saw in Freenode#ruby-lang
last week, I would like very much to remember the nick of who showed it but I
can't remember.
It seems one-liners are not at the heart of the Ruby community, but hey,
that's funny in the end. Can you shorten it?
-- fxn
[*] http://www.jwz.org/hacks/scrmable.pl
according to some English university the order of letters in words are not
really relevant for reading as long as the first and the last are at the
right place. (It seems that do not hold in Spanish).
There is a link to a Perl filter[*] that munges a given text that way and I
wanted to write a mock-up as a one-liner, but in Ruby this time. This is
what I have for now:
-pe 'gsub!(/\w+/){|w|r=1..w.size-1;w[r]=w[r].split(//).sort_by{rand}.to_s;w}'
The cool Array.sort_by { rand } trick is a shuffle I saw in Freenode#ruby-lang
last week, I would like very much to remember the nick of who showed it but I
can't remember.
It seems one-liners are not at the heart of the Ruby community, but hey,
that's funny in the end. Can you shorten it?
-- fxn
[*] http://www.jwz.org/hacks/scrmable.pl