I am using Intermediate Student with Lambda in DrRacket, I was wondering how one would remove the duplicates in a list, while keeping the order. For example (remo
What you need to do is compare in reverse order the entire time. You can use the reverse
function which returns a list in reverse order. That way you are always removing the 2nd+ occurrence of an element and not the first. Here is an example, however it is using let
and if
and not a cond
expression.
http://www.cs.bgu.ac.il/~elhadad/scheme/duplicates.html
Good luck with your homework :)