
Neil Mitchell wrote:
Hi
A nice auxiliary would help:
showEqn :: Int -> [Double] -> String showEqn i vs = ... where (add,ans) = (init vs, last vs)
Then you can half the complexity. There are probably a few useful functions that aren't in the standard libraries (consperse, joinWith etc) that you could make use of.
OK, I'll give that a go... (Actually, at present it's an "augmented matrix", represented as [[Double]]. I'm thinking by making it a matrix and seperate vector, I could reduce the runtime quite significantly by making it much faster to get hold of the RHS.) BTW, one *extremely* common function that I've never seen mentioned anywhere is this one: map2 :: (a -> b) -> [[a]] -> [[b]] map2 f = map (map f) I cannot understand why this isn't already in the standard libraries...
You seem to be doing take 8 on the double - what if the double prints out more information than this as the result of show? 1000000000000000000 could end up a bit smaller.
The contents of the matrix are random numbers between 0 and 100. The problems happen if one of the numbers turns out to be something like "3.5847368473587e-27" or something. Then it will look many thousands of times BIGGER! ;-) Still, since Haskell seems to be devoid of any more advanced way of formatting numbers beyond low-level character jiggling...