Need help writing simple Haskell program please

  • Thread starter Thread starter chuy52506
  • Start date Start date
  • Tags Tags
    Program Writing
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
chuy52506
Messages
77
Reaction score
0
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]
 
Physics news on Phys.org