···## assumes 5 possible vote categories, but easily adaptable
DEFAULT_PRIOR = [2, 2, 2, 2, 2]
def score votes, prior=DEFAULT_PRIOR posterior = votes.zip(prior).map { |a, b| a + b } sum = posterior.inject { |a, b| a + b } posterior. map.with_index { |v, i| (i + 1) * v }. inject { |a, b| a + b }. to_f / sum end···
求这段代码什么意思,不是搞 ruby,被限制发帖的路过。