• 路由表的问题? at 2014年03月17日

    ···## assumes 5 possible vote categories, but easily adaptable

    DEFAULT_PRIOR = [2, 2, 2, 2, 2]

    input is a five-element array of integers

    output is a score between 1.0 and 5.0

    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,被限制发帖的路过。