small medium large xlarge

Generic-user-small
23 Jun 2017, 16:16
Ryan (1 post)

I’m sorry, I have read this question a million times and even looked at other’s solutions online and I still have absolutely no idea what this question is actually asking.

“Write a sort that takes a list and a function that compares its two arguments and then returns a sorted list.”

The meaning of this sentence is so hard for me to understand. I have written sorts in Haskell and understand the other questions, but what the heck is this talking about?

A function that compares what two arguments? The two arguments of the sort? Two random arguments of the function? Two elements of the list? I am so confused.

If someone understands this, can you please re-word the sentence for me?

Thank you!

Generic-user-small
17 Jul 2017, 21:15
freddie stewart (1 post)

Haven’t gotten into Haskell yet - relying on experience with functional style programming using Groovy.

My interpretation: “Write a function that takes as its arguments a list and a sorting function, compares these arguments, and outputs a sorted list.”

I take it the “outer” function is a generic function that outputs a version of the list arg that is sorted according to the logic of the function arg. By passing in different functions along with compatible list types, the generic function can be called to sort different list types in different orders.

You must be logged in to comment