From: Alan Chen Date: 2002-04-20T01:27:11+09:00 Subject: Re: Ruby golf (FFT) Was: Freshmeat article about Ruby On Sat, Apr 20, 2002 at 01:11:54AM +0900, David Alan Black wrote: > Hello -- > > On Sat, 20 Apr 2002, Christian Szegedy wrote: > > > I start the golf game: > > I highly recommend including the following disclaimer in every > golf-related post: > > DISCLAIMER: I do not believe that reducing code to the > smallest possible size is always or even usually a good > idea. However, I tend to learn a lot about Ruby from > this kind of exercise, and that's why I do it. > > :-) > > > (The function fft modifies the vals array in place. > > It must hold 2**n complex numbers.) > > > > require "complex" > > > > def fft(vals,n) > > size = 2**n > > j=0 > > vals.map { |x| x/Math.sqrt(size) } > > Shouldn't that be map! ? Otherwise the result gets thrown away. > Heh, maybe we should write a unit test so that we can golf faster ;) -- Alan Chen Digikata LLC http://digikata.com