[Haskell-beginners] code critique

Bryce Verdier bryceverdier at gmail.com
Tue Jul 26 05:52:01 CEST 2011


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110725/a34927ff/attachment.htm>


More information about the Beginners mailing list