1 msgBad file descriptor - connect(2) (Errno::EBADF)
1 msg[ANN] RubyKaigi2008 Tickets and News
2 msgin `include': wrong argument type Class ???
7 msgverify installation
34 msg[QUIZ] The Turing Machine (#162)
10 msgWhich GUI library to use?
1 msgForm_remote_tag and csv download?
3 msgDownload resume with NET::HTTP

Delete every other value in an array
\ Tim Conner (9 May 2008)
. \ Harry Kakueki (9 May 2008)
. . \ Harry Kakueki (10 May 2008)
. . . \ Harry Kakueki (11 May 2008)
. \ yermej (9 May 2008)
. . \ ara.t.howard (9 May 2008)
. \ Raúl GutiérrezS. (9 May 2008)
. . \ ara.t.howard (9 May 2008)
. \ James Gray (9 May 2008)
. \ ara.t.howard (9 May 2008)
. \ Robert Dober (9 May 2008)
. . \ Robert Dober (9 May 2008)
. \ Joel VanderWerf (10 May 2008)
. \ yermej (10 May 2008)
. \ 7stud -- (10 May 2008)
. . \ David A. Black (10 May 2008)
. . . \ 7stud -- (10 May 2008)
. \ S2 (10 May 2008)

1 msgrunning a script through remote desktop
4 msgUsing Derrick Pallas' ruby fcgi dispatcher
2 msgActive Record: Query to find all the tables in ...
3 msgvalidation for file
3 msgRe: Bootstrapping Ruby with MinGW: selfhosted a...
1 msgRe: Bootstrapping Ruby with MinGW: selfhosted a...
3 msghow to do this regex substitution?
1 msgHI.How to install instal qtruby4-1.4.9-mswin32....
5 msgHow to re-replace Hash default value behaviour?
5 msgPrinciple of le,err i mean biggest surprise!!??
1 msgRMagick 1.15.14
Subject:Re: Delete every other value in an array
Group:Ruby-talk
From:Harry Kakueki
Date:11 May 2008


 
>>
>>
>
> Oops. My code has a bug.
>
> arr = %w[a b c d b f g h i j k l m]
>
> p arr.select{|x| arr.index(x) % 2 == 0}#> ["a", "c", "g", "i", "k", "m"]
>
> res = []
> (0...arr.length).step(2) {|x| res << arr[x]}
> p res #> ["a", "c", "b", "g", "i", "k", "m"]
>
> Harry
>
>
Or not. :)
Which do you want?

Harry

--
A Look into Japanese Ruby List in English
http://www.kakueki.com/ruby/list.html



© 2004-2008 readlist.com