News for hackers. Stuff that matters.
Re:Side-by-side Nim and Go by jaws- on Friday April 10, 2015 @12:59PM (#9355610)
http://rosetta.alhur.es/compare/nim/go/#Matrix_arithmetic

Nim:

    proc det[M,N](a: Matrix[M,N]): float =
      let n = toSeq 0..a.high
      for sigma, sign in n.permutations:
        var x = sign.float
        for i in n: x *= a[i][sigma[i]]
        result += x
Go:

    func determinant(m [][]float64) (d float64) {
        p := make([]int, len(m))
        for i := range p {
            p[i] = i
        }
        it := permute.Iter(p)
        for s := it(); s != 0; s = it() {
            pr := 1.
            for i, σ := range p {
                pr *= m[i][σ]
            }
            d += float64(s) * pr
        }
        return
    }
I don't know anything about Go or Nim, but the Nim version looks infinitely more readable to me.

There are no comments on this comment yet.