(define (downup wd) (if (= (count wd) 1) (se wd) (se wd (downup (bl wd)) wd))) (define (pigl wd) (if (member? (first wd) 'aeiou) (word wd 'ay) (pigl (word (bf wd) (first wd))))) (define (explode wd) (if (empty? wd) '() (se (first wd) (explode (bf wd))))) (define (letter-pairs wd) (if (<= (count wd) 1) '() (se (first-two wd) (letter-pairs (bf wd))))) ;;first-two is a helper for letter-pairs, not a recursive procedure on its own (define (first-two wd) (word (first wd) (first (bf wd)))) (define (reverse wd) (if (= (count wd) 1) wd (word (last wd) (reverse (bl wd))))) (define (factorial n) (if (= n 1) 1 (* n (factorial (- n 1))))) (define (evens sent) (if (<= (count sent) 1) '() (se (first (bf sent)) (evens (bf (bf sent)))))) (define (copies n wd) (if (= n 0) '() (se (copies (- n 1) wd) wd))) (define (sum-in-interval intvl) (if (> (first intvl) (first (bf intvl))) 0 (+ (first intvl) (sum-in-interval (se (+ 1 (first intvl)) (first (bf intvl))))))) (define (appearances letter-or-wd wd-or-sent) (cond ((empty? wd-or-sent) 0) ((equal? letter-or-wd (first wd-or-sent)) (+ 1 (appearances letter-or-wd (bf wd-or-sent)))) (else (appearances letter-or-wd (bf wd-or-sent))))) (define (is-palindrome? wd) (cond ((<= (count wd) 1) #t) ((equal? (first wd) (last wd)) (is-palindrome? (bl (bf wd)))) (else #f))) (define (0-up-to n) (if (< n 0) '() (se (0-up-to (- n 1)) n) (define (down-to-0 n) (if (< n 0) '() (se n (down-to-0 (- n 1))) (define (remove char wd) (cond ((empty? wd) wd) ((equal? char (first wd)) (remove char (bf wd))) (else (word (first wd) (remove char (bf wd)))))) (define (sent-max sent) (if (= (count sent) 1) (max (first sent) (sent-max (bf sent))))) (define (all-odd-1? sent) (cond ((empty? sent) #t) ((odd? (first sent)) (all-odd-1? (bf sent))) (else #f))) (define (all-odd-2? sent) (or (empty? sent) (and (odd? (first sent)) (all-odd-2? (bf sent))))) (define (dupls-removed sent) (cond ((empty? sent) '()) ((member? (first sent) (bf sent)) (dupls-removed (bf sent))) (else (se (first sent) (dupls-removed (bf sent)))))) (define (is-sorted? sent) (cond ((empty? sent) #t) ((empty? (bf sent)) #t) ((<= (first sent) (first (bf sent))) (is-sorted? (bf sent))) (else #f)))