Skip to content

Instantly share code, notes, and snippets.

@samth
Forked from dyoo/find-duplicates.rkt
Created January 31, 2013 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samth/4681119 to your computer and use it in GitHub Desktop.
Save samth/4681119 to your computer and use it in GitHub Desktop.
#lang racket
(define (find-duplicates elts)
(define ht (make-hash))
(for/list ([x elts]
#:when (hash-update! ht x add1 0)
#:when (= 2 (hash-ref ht x)))
x))
(find-duplicates '(1 2 2 3 1 4 5 4 4 4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment