-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhw08.scm
More file actions
15 lines (12 loc) · 882 Bytes
/
Copy pathhw08.scm
File metadata and controls
15 lines (12 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(define (my-filter func lst)(cond ((null? lst) '())((func (car lst))
(cons (car lst) (my-filter func (cdr lst))))
(else (my-filter func (cdr lst)))))
(define (interleave s1 s2) (cond ((and (null? s1) (null? s2))
nil)((null? s1) (interleave s2 s1))
(else (cons (car s1) (interleave s2(cdr s1))))))
(define (accumulate merger start n term)
(cond ((= n 1)(merger (term n) start))(else (merger (term n)
(accumulate merger start(- n 1)term)))))
(define (no-repeats lst) (cond ((null? lst) nil)(else (cons (car lst)
(no-repeats(my-filter (lambda (x)
(not (= x (car lst)))) (cdr lst)))))))