This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

How do i check a list has distinct objects(is a set?) or not

1 post · 2153 views

I am trying to write a function in scheme which is checking a list is a set or not.

In C algorithm would be like this:
int count = sizeof(array) / sizeof(array[0]);

for (int i = 0; i < count - 1; i++) { 
    for (int j = i + 1; j < count; j++) {
        if (array[i] == array[j]) {
            //return false
        }
    }
}
(define set? (lambda (lst)
...
))