- #1
chuy52506
- 77
- 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]
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]