Skip to content

Instantly share code, notes, and snippets.



Created Aug 20, 2011
What would you like to do?
import Data.List(find)
findSum :: Num a => a -> [a] -> Bool
findSum s ns = find (sumIs s) (pairs ns)
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