0

I'm stuck on this exercise of functional programming in Poly/ML:

Do a function of type ''a list -> int so that it takes a list of ''a elements as argument. The function has to return the number of elements in the list without counting duplicates.

I really have no idea about how to solve it.

Thanks in advance for the help!

1 Answers1

0

Reformulate that a little bit: "the number of unique elements in the list", which is "the length of the list after you have removed duplicates".

You probably already know how to find the length of a list, so that's one subproblem solved.

Now you have "remove duplicate elements from a list" left, which I leave as an exercise.
("Remove one particular value from a list" is probably a good step to include.)

molbdnilo
  • 64,751
  • 3
  • 43
  • 82