Partial Applications

  • + 0 comments
    combination = -> (n) do
        -> (r) do
            diff = n - r
            nfact = (1..n).inject(:*) || 1
            rfact = (1..r).inject(:*) || 1
            diffact = (1..diff).inject(:*) || 1
            nfact/(rfact*diffact)
        end
    end