Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;2
- (define (sumFib lst)
- (define l (length lst))
- (define (iter a b sum)
- (if (= 1 l) (car lst)
- (if(< a l)
- (iter b (+ a b) (+ (list-ref lst a) sum))
- (- sum (cadr lst)))))
- (iter 0 1 0))
- ;3
- (define (function1 x y)
- (define (fact n)
- (define (fun x lst i)
- (if (or (> i n) (= i x)) (reverse (cons i lst))
- (if (= (remainder x i) 0) (fun (/ x i) (cons i lst) i)
- (fun x lst (+ i 1)) )))
- (fun n '() 2))
- (define (Fun lst)
- (define (fun ans lest )
- (if (empty? lest) #t
- (if (member (car lest) ans) #f
- (fun (cons (car lest) ans) (cdr lest) ))))
- (fun '() lst ))
- (define (del n)
- (if (Fun (fact n)) #f #t))
- (define (otr a b)
- (define (fun2 i ans)
- (if (> i b) (reverse ans)
- (fun2 (add1 i) (cons i ans))))
- (fun2 a '()))
- (filter del (otr x y)))
- ; первая задача
- (define (derivative lst)
- (define (fun z n a)
- (if (empty? z) #f
- (if (= 1 (length z)) (reverse n)
- (fun (cdr z) (cons (* (car z) (- a 1)) n) (- a 1)))))
- (fun lst '() (length lst)))
- ; 2 task
- (define (Sum lst1 lst2 )
- (define a (length lst1))
- (define b (length lst2))
- (cond ((= a b)(map + lst1 lst2))
- ((< a b)(map + (append (make-list (- b a) 0) lst1) lst2))
- ((< b a)(map + (append (make-list (- a b) 0) lst2) lst1))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement