Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (rmvfrom elem seq)
- (cond ((null? seq) '())
- ((= elem (car seq)) '())
- (else (cons (car seq) (rmvfrom elem (cdr seq))))
- )
- )
- (define (maax a b)
- (if (> (length a) (length b)) a b)
- )
- (define (uniq seq)
- (if (null? seq) '(() ())
- (let ((next (uniq (cdr seq))))
- (let ((cur (cons (car seq) (rmvfrom (car seq) (car next)))))
- (list cur (maax cur (cadr next)))
- )
- )
- )
- )
- (define (longestUniqum seq)
- (cadr (uniq seq))
- )
- (display (longestUniqum '(3 4 1 2)))(newline)
- (display (longestUniqum '(2 3 4 1 2)))(newline)
- (display (longestUniqum '(4 2 3 4 1 2)))(newline)
- (display (longestUniqum '(3 4 2 3 4 1 2)))(newline)
- (display (longestUniqum '(2 3 4 2 3 4 1 2)))(newline)
- (display (longestUniqum '(1 2 3 4 2 3 4 1 2)))(newline)
- (display (longestUniqum '(1 2 5 3 5 6 5 4 3)))(newline)
- (display (longestUniqum '(1 2 3 1 3 2)))(newline)
- (define (help n i)
- (if (= i 1) 1
- (+ (help n (- i 1))
- (if (and (= 1 (mod i 2)) (= 0 (mod n i)) )
- i 0
- )
- )
- )
- )
- (define (odd-divisors n)
- (help n n)
- )
- (display (odd-divisors 24))(newline)
- (display (odd-divisors 17))(newline)
- (display (odd-divisors 15))(newline)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement