[Haskell-cafe] Very crazy
Dougal Stanton
ithika at gmail.com
Tue Sep 25 05:31:34 EDT 2007
On 25/09/2007, Andrew Coppin <andrewcoppin at btinternet.com> wrote:
> Type signature is
>
> show_system :: [[Double]] -> String
>
> It takes a matrix representing a system of equations, and pretty prints
> it. Unfortunately, doing complex formatting like that is... well,
> 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. ;-)
In this instance I would suggest:
(1) Text.Printf
(2) Pull out some of those things into separate functions with
where/let clauses.
If it's a matrix you should probably have something like
> showMatrix = concatMap showRow
Since you'll be applying the same procedures to each line of digits.
Cheers,
D.
More information about the Haskell-Cafe
mailing list