Kyle Krull
Kyle Krull

Reputation: 1708

Scheme: Detecting duplicate elements in a list

Does R6RS or Chez Scheme v7.9.4 have a library function to check if a list contains duplicate elements?

Alternatively, do either have any built in functionality for sets (which dis-allow duplicate elements)? So far, I've only been able to find an example here.

The problem with that is that it doesn't appear to actually be part of the Chez Scheme library. Although I could write my own version of this, I'd much rather use a well known, tested, and maintained library function - especially given how basic an operation this is.

So a simple "use these built-in functions" or a "no built-in library implements this" will suffice. Thanks!

Upvotes: 5

Views: 2286

Answers (2)

dharmatech
dharmatech

Reputation: 9497

Kyle,

Awhile back I needed to use a few SRFIs with Chez Scheme. A few that a converted for use with Chez Scheme (including SRFI-1) are at:

http://github.com/dharmatech/chez-srfi

After you add the path to 'chez-srfi' to your CHEZSCHEMELIBDIRS, you can import SRFI-1:

(import (srfi :1))

Ed

Upvotes: 3

mqp
mqp

Reputation: 71937

SRFI 1 on list processing has a delete-duplicates function (so you could use that and check the length afterward) and may well have other functions you might find useful.

Upvotes: 4

Related Questions