Untitled

mail@pastecode.io avatar
unknown
scheme
a month ago
279 B
2
Indexable
Never
#lang racket
(define/contract (contains-duplicate nums)
  (-> (listof exact-integer?) boolean?)
    (cond
      [(null? nums) (#f)]
      [(list? (member (car nums) (cdr nums))) (#t)]
      [else (contains-duplicate (cdr nums))])
    )

(contains-duplicate '(1 2 3 4 5))
Leave a Comment