Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #lang racket
- (define (rev lst)
- (match lst
- ['() '()]
- [(list a) (list a)]
- [(cons h t)
- (append
- (rev t)
- (list h))]))
- (define (annihilate lst pred)
- (match lst
- ['() '()]
- [(list a) (if (pred a) '() (list a))]
- [(cons h t)
- (let ([nt (annihilate t pred)])
- (if (pred h)
- nt
- (cons h nt)))]))
- (displayln (annihilate '(1 2 3 4 5 6 7 8 9 10) (λ (n) (odd? n))))
- (displayln (rev '(1 2 3 4 5 6)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement