duplicate removal - Haskell - Create Set (unique sorted list) - no recursion, no nub -


Is it possible to create a function that will create a set with the input of a list?

I can not think of any type without using recursive

I can use the high order function such as fold, filter, map, zip. I can not recycle my function

Obviously I can not use the nib.

I am trying to find out my head how to get rid of duplicates without recurring or any kind of loop (at least I do not think we can use loop, ask Want)

One way to do this:

  1. Sort the list.
  2. Pin the list with your tail (like [1,1,2,3]] in [(1,1), (1,2) , (2,3)] )
  3. Remove all the joints where the two items are the same.
  4. Return the list containing the first element of the sorted list after the second item of each pair in the ziped list.

In the code:

  Import data. Install the list [] = [] XS = X: Map SD (filter (uncontrollable (= =)) (zip sxs (tail sxs))) where sxs = sort xs x = head sxs set  

Comments