From: Simon Strandgaard Date: 2003-11-21T01:22:24+09:00 Subject: Re: learning the "Ruby way" On Thu, 20 Nov 2003 01:06:25 -0800, Mark Wirdnam wrote: > Is this the "Ruby way" of solving this problem? I doubt it, defining > "helper variables" like this is what had to be done in Basic, and my > solution doesn't demonstrate the high degree of readability Ruby is often > praised for. > > Any useful suggestions for me? I'd be very grateful! > Mark How about this dirty solution ? server> ruby a.rb ["-a-", "alfred", "-b-", "boris", "bruce", "-c-", "claire", "-d-", "dean", "donald"] server> expand a.rb names = %w(alfred boris bruce claire dean donald) letters = names.map{|name| n=name[0..0]; [n, "-#{n}-"]}.uniq p (letters + names.zip(names)).sort.transpose[1] server> -- Simon Strandgaard