Search found 2 matches
- Thu Apr 26, 2018 10:33 am
- Forum: Homework
- Topic: How do i check a list has distinct objects(is a set?) or not
- Replies: 0
- Views: 85631
How do i check a list has distinct objects(is a set?) or not
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 se...
- Thu Apr 26, 2018 10:32 am
- Forum: Homework
- Topic: Check element is in list or not Scheme
- Replies: 0
- Views: 84961
Check element is in list or not Scheme
I am trying to write a function which is checking whether element is in list(return true) or not(return false.) (define in? (lambda ('el lst) (cond ((member el lst '#t) (else '#f))) )) (in? 3 '(2 5 3)) In this case my expected output is #t but i get Error: execute: unbound symbol: "el" [in...