[Haskell-beginners] code critique

KC kc1956 at gmail.com
Tue Jul 26 07:36:27 CEST 2011


Hi:

I think you may want to use a hash table.


Are you looking for algorithm improvement

and/or

coding improvement?



On Mon, Jul 25, 2011 at 8:52 PM, Bryce Verdier <bryceverdier at gmail.com> wrote:
> Hi all,
> I'm new to haskell, and I'm trying to get better with it. Recently I
> completed one of the challenges from Programming Praxis and I was wondering
> if people would be willing to spend some time and tell me how I could
> improve my code.
> Thanks in advance,
> Bryce
> Here is a link to the programming praxis:
> http://programmingpraxis.com/2011/07/19/sum-of-two-integers/
> And here is my code:
> import Data.List
> import Data.Maybe
> sumCheck :: Int -> [Int] -> [Int] -> Maybe (Int, Int)
> sumCheck _ [] _ = Nothing
> sumCheck total (x:xs) ys = if total' == Nothing
>                                 then sumCheck total xs ys
>                                 else return (x, (ys !! ( fromJust total')))
>                            where total' = (total - x) `elemIndex` ys
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>



-- 
--
Regards,
KC



More information about the Beginners mailing list