How do i check a list has distinct objects(is a set?) or not
Posted: Thu Apr 26, 2018 10:33 am
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:
In C algorithm would be like this:
Code: Select all
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
}
}
}
Code: Select all
(define set? (lambda (lst)
...
))