Need help writing simple Haskell program please

In summary, Haskell is a functional programming language with a strong type system and the ability to handle complex data structures. It offers benefits such as better code readability and built-in support for concurrency and parallelism. To get started writing a simple Haskell program, you need to download a compiler, familiarize yourself with the syntax and basic concepts, and start writing and testing your code. Some common errors and challenges include type and syntax errors, as well as understanding advanced concepts like monads and lazy evaluation. However, there are many online resources and communities available to help, such as tutorials, forums, and meetups.
  • #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]
 
Technology news on Phys.org
  • #2
anyone??
 
Back
Top