;;; ;;; Recursive patterns ;;; ;;; Write each higher order procedure and confirm ;;; that it works similary to the built-in procedure. ;;; ;;; Also try writing the higher order procedures: ;;; - find-first ;;; - test-all ;;; - count-true ;;; (define (every proc sent) "") (define (keep pred sent) "") (define (accumulate cmbr sent) "") ;; (find-first odd? '(2 4 1 5)) -> 1 (define (find-first pred sent) "") ;; (test-all odd? '(3 1 2 4)) -> #f (define (test-all pred sent) "") ;; (count-true odd? '(1 1 2 3 1 4)) -> 4 (define (count-true pred sent) "") ;;; ;;; Zip ;;; ;;; Write a procedure that weaves to sentences ;;; together. ;;; ;;; (zip '(1 2 3) '(a b c d e)) ;;; -> (1 a 2 b 3 c d e) ;;; ;;; (Make it as short as you possible can) ;;; (define (zip sent1 sent2) "") ;;; ;;; Reverse ;;; ;;; Write reverse using higher order procedures. ;;; ;;; (Make it work for words AND sentences) ;;; (define (reverse wd-or-sent) "") ;;; ;;; Repeated ;;; ;;; Write repeated, which takes in a procedure with ;;; one argument and a number 'n', and returns a procedure ;;; that is executed n times. ;;; (define (repeated proc n) "") ;;; ;;; Factors! ;;; ;;; Write a procedure that given a number it will return ;;; a sentence of its factors. ;;; ;;; After that, write a procedure to find the GCF ;;; (greatest common factor), and a procedure to find ;;; the LCM (least common multiple). ;;; ;;; (I know gcd and lcm are already defined, but practice ;;; writing it on your own) ;;; (define (factors num) "") (define (gcf x y) "") (define (lcm x y) "") ;;; ;;; Pascal Row ;;; ;;; Given a row number, write a procedure that returns the ;;; numbers in that row. ;;; ;;; Example (pascal-row 2) -> (1 2 1) ;;; (define (pascal-row row) "") ;;; ;;; Calculator ;;; ;;; Given a sentence like (1 + 2 * 3 / 4 - 19), evaluate ;;; the arithmetic expression in order (order of operations). ;;; ;;; (Try doing it recursively and with HOF) ;;; (define (calc sent) "" ) ;;; ;;; snack-n ;;; ;;; Count the number of ways there are of eating n snacks. ;;; ;;; (sent is a sentence of numbers representing snacks) (define (snack-n sent) "")