Alex K.

asked • 05/14/22

Haskell - I am not sure how to use the pairs function with list comprehension to solve this question in Haskell

The function pairs :: [a] -> [(a,a)] returns the list of pairs of adjacent elements of a list. For instance, pairs [3,4,5,6] = [(3,4),(4,5),(5,6)].

Use the function pairs and a list comprehension to define the following function sorted :: Ord a => [a] -> Bool that decides if the input list is sorted in ascending order and has no repetition.


For instance, sorted [1,2,3] should be True, while both sorted [2,1,3] and sorted [1,1,3] should be False.




1 Expert Answer

By:

Daniel F. answered • 06/06/22

Tutor
New to Wyzant

Professional Developer Specializing in Python

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.