Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Need help writing simple Haskell program please

  1. May 7, 2012 #1
    So for my program I want to input this line of code:

    addPairs 10 [(2,3),(4,15),(87,92),(23,45)]

    Where the 10 after addPairs is the minimum distance the pair (x,y) must have in order to be outputted as [x+y]
    For example :
    addPairs 10 [(2,3),(4,15),(87,92),(23,45)]

    would output:
    [ 19, 68 ]

    SO far this is what I have:

    diffTuple :: (Int,Int) -> Int
    diffTuple (x,y) = abs (x-y)

    addDistantPairs :: addDistantPairs :: Int -> [(Int,Int)] -> [ Int ]
    addDistantPairs n [(x,y)]
    | diffTuple(x,y)>= n = addPairs[(x,y)]
    | otherwise = [0]
     
  2. jcsd
  3. May 9, 2012 #2
    anyone??
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Need help writing simple Haskell program please
  1. Haskell help (Replies: 2)

Loading...