How to get rid of duplicates in a list, but keep the order

前端 未结 8 1298
情话喂你
情话喂你 2021-02-15 15:13

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

8条回答
  •  一个人的身影
    2021-02-15 16:13

    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 :)

提交回复
热议问题