Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Common Lisp have a something like java's Set Interface/implementing classes?

Tags:

java

set

lisp

sbcl

I need something like this, a collection of elements which contains no duplicates of any element. Does Common Lisp, specifically SBCL, have any thing like this?

like image 743
Paul Wicks Avatar asked Oct 03 '08 05:10

Paul Wicks


2 Answers

For a quick solution, just use hash tables, as has been mentioned before.

However, if you prefer a more principled approach, you can take a look at FSet, which is “a functional set-theoretic collections library”. Among others, it contains classes and operations for sets and bags.

(EDIT:) The cleanest way would probably be to define your set-oriented operations as generic functions. A set of generic functions is basically equivalent to a Java interface, after all. You can simply implement methods on the standard HASH-TABLE class as a first prototype and allow other implementations as well.

like image 143
Matthias Benkard Avatar answered Oct 19 '22 05:10

Matthias Benkard


Look at cl-containers. There is a set-container class.

like image 39
Jacek Szymański Avatar answered Oct 19 '22 03:10

Jacek Szymański