Search found 2 matches

by lastpeony
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: 2218

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...
by lastpeony
Thu Apr 26, 2018 10:32 am
Forum: Homework
Topic: Check element is in list or not Scheme
Replies: 0
Views: 1508

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?] error. ...