< :the previous in number
^ :the list in numerical order
> :the next in number
P :the previous (in thread)
N :the next artilce (have the same parent)
|<:the top of this thread
>|:the next thread
^ :the parent (reply-to)
_:the child (an article replying to this)
>:the elder article having the same parent
<:the youger article having the same parent
---:split window and show thread lists
| :split window (vertically) and show thread lists
~ :close the thread frame
.:the index
..:the index of indices
On May 2, 2007, at 3:18 PM, Daniel Martin wrote:
> Just one minor nit:
>
> Christian Neukirchen <chneukirchen / gmail.com> writes:
>
>> def luhn?(n)
>> f = 2
>> (n.delete("^0-9").reverse.split(//).map{|d|d.to_i}.
>> inject(0) { |a,e| f=3-f; a + (e*f > 9 ? e*f-9 : e*f) } %
>> 10).zero?
>> end
>
> You do know that (e*f > 9 ? e*f-9 : e*f) is equivalent to e*f%9,
> right?
>> (0..9).map { |n| n * 2 % 9 }
=> [0, 2, 4, 6, 8, 1, 3, 5, 7, 0]
>> (0..9).map { |n| n * 2 > 9 ? n * 2 - 9 : n * 2 }
=> [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]
James Edward Gray II