Hacker News new | ask | show | jobs
by ridiculous_fish 3993 days ago

    addart a = array ((-1,0),(n,m+n)) $ z ++ xsi ++ b ++ art ++ x
      where z = ((-1,0), a!(0,0)) : [ ((-1,j),0) | j <- [1..n] ] ++ [ ((-1,j+n),a!(0,j)) | j <- [1..m] ]
            xsi = ((0,0), -colsum a 0) : [ ((0,j),0) | j <- [1..n] ] ++ [ ((0,j+n), -colsum a j) | j <- [1..m] ]
            b = [ ((i,0), a!(i,0)) | i <- [1..n] ]
            art = [ ((i,j), if i == j then 1 else 0) | i <- [1..n], j <- [1..n] ]
            x = [ ((i,j+n), a!(i,j)) | i <- [1..n], j <- [1..m] ]
            ((_,_),(n,m)) = bounds a

From Matrix.Simplex https://hackage.haskell.org/package/dsp-0.2.1/docs/src/Matri...
2 comments

https://hackage.haskell.org/package/dsp-0.2.1/docs/src/Matri... link to the function itself

Never really seen something like this before, really hope someone will clean it up

To be fair it looks to be a relatively complex operation. Do you know how any other languages implement this?
This is not about the complexity of the code, but about variables with or without meaningful names.
I feel like xsi and art mean something domain specific that might be obvious to a domain expert.