Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (display
- (letrec* ([the-list (read)]
- [even-elts (lambda (l)
- (if (or (null? l)
- (null? (cdr l)))
- '()
- (cons (cadr l)
- (even-elts (cddr l)))))]
- [the-even-elts (even-elts the-list)]
- [sorted? (lambda (l)
- (if (null? l)
- #t
- (let ([tail (cdr l)])
- (if (null? tail)
- #t
- (and (< (car l) (car tail))
- (sorted? tail))))))]
- [positive-indices-iter (lambda (l index indices)
- (if (null? l)
- indices
- (positive-indices-iter
- (cdr l)
- (1+ index)
- (if (negative? (car l))
- indices
- (append indices (list index))))))]
- [positive-indices (lambda (l) (positive-indices-iter l 0 '()))])
- (if (sorted? the-even-elts)
- (fold-left * 1 the-even-elts)
- (positive-indices the-list))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement