[Haskell-cafe] Very crazy

Neil Mitchell ndmitchell at gmail.com
Tue Sep 25 05:36:16 EDT 2007


> complex. The input is quite simple (it's a bunch of numbers), the output
> is quite simple (it's a neatly formatted string), but the process in the
> middle is... a mess. I'd like to find a more readable way of doing stuff
> like this. It's not just this specific function; any general hints would
> be good. ;-)

A nice auxiliary would help:

showEqn :: Int -> [Double] -> String
showEqn i vs = ...
          (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.

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.



More information about the Haskell-Cafe mailing list