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

前端 未结 8 1278
情话喂你
情话喂你 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 15:58

    If your goal is to get the functionality working, and not some homework question, then you don't need to do anything, just use remove-duplicates:

    Welcome to Racket v5.2.
    -> (remove-duplicates (list 2 5 4 5 1 2))
    '(2 5 4 1)
    

提交回复
热议问题