Created
January 19, 2014 09:36
-
-
Save leontastic/8502497 to your computer and use it in GitHub Desktop.
A clone of the *remove-duplicates* built-in function in Racket. Uses *equal?* to determine if two elements are duplicates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; remove-duplicates-clone: (listof Any) -> (listof Any) | |
; (remove-duplicates-clone loa) produces loa without duplicated elements while preserving the order of elements | |
(define (remove-duplicates-clone loa) | |
(foldr (lambda (x y) (cons x (filter (lambda (z) (not (equal? x z))) y))) empty loa)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment