tags:

views:

310

answers:

2

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!

+4  A: 

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.

mquander
Thanks - looks like this would be a useful function. Any idea when SRFI 1 will make it into Chez Scheme? It already seems to have much of what this SRFI has to offer, but I'm not seeing delete-duplicates anywhere in v7.9.4.
Kyle Krull
I use PLT and I don't know anything about Chez, but many SRFIs should be available for any popular Scheme implementation; they're basically the big standard libraries for Scheme. Google found this immediately: https://code.launchpad.net/~scheme-libraries-team/scheme-libraries/srfi These SLS (Scheme library source) files should be loadable via Chez, perhaps like this: http://www.scheme.com/csug8/libraries.html
mquander
Thanks. It looks like this would probably work, although I haven't had a chance to download enough source to try loading it into Chez.
Kyle Krull
+3  A: 

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

dharmatech
This looks really useful, but I keep getting "Exception: library (srfi :1) not found" when I try the import command in the scheme interpreter. I've tried setting CHEZSCHEMELIBDIRS, running with --libdirs, and running scheme from .../chez-srfi, but it's always the same result.I'm not sure if this is related, but git didn't seem to like the files containing '*' when I cloned the repository.
Kyle Krull
Yikes, sorry for not responding earlier; I haven't checked stack overflow much lately. Are you on Windows? Unfortunately those srfi libraries use a naming convention which isn't supported on Windows (crazy I know...). I'm thinking about putting out copy of that collection which uses "portable" names.
dharmatech
No problem. I am on Windows, so you can count at least one fan if you get a chance to release the portable version of the library :)
Kyle Krull