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

前端 未结 8 1253
情话喂你
情话喂你 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条回答
  •  梦毁少年i
    2021-02-15 16:04

    This is the solution:

    (define (remove-duplicates lon)
      (foldr (lambda (x y) (cons x (filter (lambda (z) (not (= x z))) y))) empty lon))
    

提交回复
热议问题