[Haskell-cafe] Is this haskelly enough? -- errm but every answer is wrong(?)

Dan Weston westondan at imageworks.com
Tue Jul 17 21:08:22 EDT 2007


Correct, efficient, elegant: you can only have two out of three. I see 
where your priorities lie! :)

Dan

Anthony Clayden wrote:
> (Or at least the problem is under-specified.)
> 
> 1. There may be several sub-sequences having the maximum
> sum.
>    So the type for the solution should be :: Num a => [a] ->
> [[a]]
>    (Note that the problem didn't ask for the maximum
> itself.)
> 
> 2. The inits . tails approach adds a fault:
>    It introduces a sprinkling of empty sub-sequences. These
> have sum zero.
>    So in case the input list is all negative numbers ...
> 
> Being a software tester for my day job, I looked first not
> for an elegant and/or efficient solution; but for where to
> stretch the boundaries of the problem.
> 
> 
>> However, the key point is that this is a TRICK QUESTION.
> 
> <snip>
> 
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 




More information about the Haskell-Cafe mailing list