El Thu, 24 de Sep de 2009, a las 01:56:05PM -0300, p8queen dijo:
> Gracias. Por las respuestas. Va de nuevo el enunciado.
> 
> La solucion no son los indices, sino los valores cuyos indices sean
> congruentes a 0 modulo 4
> ejemplo:
> dado c = %w{diego luis wilson santiago leandro lucas mariana paula
> analia fernando marcela}
> salida --> diego, leandro, analia
esta estaría un poco más corta:

c.each_with_index.map{|n, i| n if i % 4 == 0}.compact!



> 
> 
> PD: en otro lenguaje la solucion es c[::4]
> 
> -- 
> gustavo c
> _______________________________________________
> Ruby mailing list
> [email protected]
> http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar

-- 
"Most of you are familiar with the virtues of a programmer.  There are three, of
course: laziness, impatience, and hubris."

(Larry Wall)


+-------------------------------------+
Gastón Ramos
http://gastonramos.com.ar/
GNU/Linux Counter user #450312
_______________________________________________
Ruby mailing list
[email protected]
http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar

Responder a