Created
August 20, 2011 18:44
-
-
Save md2perpe/1159478 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List(find) | |
findSum :: Num a => a -> [a] -> Bool | |
findSum s ns = find (sumIs s) (pairs ns) | |
where | |
sumIs :: Num a => a -> (a, a) -> Bool | |
sumIs s (x, y) = x+y == s | |
pairs :: [a] -> [(a, a)] | |
pairs [] = [] | |
pairs' (x:xs) = map (\y->(x,y)) xs ++ pairs xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment