From: Brian Adkins Date: 2007-04-11T00:05:09+09:00 Subject: Re: How to Write a Spelling Corrector On Tue, 10 Apr 2007 16:52:03 +0900, Robert Dober wrote: > On 4/10/07, Joel VanderWerf wrote: >> Brian Adkins wrote: >> > 3) Minor point, but apparently Python has a built in constant for the set >> > of lower case characters "string.lowercase", so I just defined a constant. >> ... >> > LETTERS = 'abcdefghijklmnopqrstuvwxyz' >> >> A minor comment: you can construct this string with >> >> ("a".."z").to_a.join >> => "abcdefghijklmnopqrstuvwxyz" > > Almost nobody, not even the gurus ever use [*a..b] instead of (a..b).to_a. Interesting. I didn't realize that would work with ranges. Here's what I read in "Programming Ruby" p. 348: "Following these parameters may be a single parameter prefixed with an asterisk. If this parameter is an array, Ruby replaces it with zero or more parameters corresponding to the elements of the array." I guess to_a is called on the range implicitly prior to evaluating *. > The performance is about the same, the former seems faster for short > arrays/ranges ~ 500 > and from about 1k elements the later gets slightly faster. > I feel that [*a..b] is the right/better/more logical construct to use > if one wants an array, or do I miss something? > > Cheers > Robert >> >> -- >> vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407 >> >>