(define myLON1 (list 1 2 3 4 5 )) (define myLON2 (list -3 2 5 -4 1 28)) ;; sumBig_rev: lon, num --> num ;; Sums all numbers in a list of numbers ;; larger than x (define (sumBig_rev a-lon x) (cond [(empty? a-lon) 0] [(cons? a-lon) (+ (cond [(> (first a-lon) x) (first a-lon)] [ else 0]) (sumBig_rev (rest a-lon) x))])) "sumBig_rev test cases:" (= 9 (sumBig_rev myLON1 3)) (= 5 (sumBig_rev myLON1 4)) (= 36 (sumBig_rev myLON2 -2)) (= 33 (sumBig_rev myLON2 2)) ;; sumBig_fwd: lon, num --> num ;; Sums all numbers in a list of numbers ;; larger than x (define (sumBig_fwd a-lon x) (cond [(empty? a-lon) 0] [(cons? a-lon) (sumBig_fwd_h (rest a-lon) x (cond [(> (first a-lon) x) (first a-lon)] [else 0]))])) (define (sumBig_fwd_h a-lon x acc) (cond [(empty? a-lon) acc] [(cons? a-lon)(sumBig_fwd_h (rest a-lon) x (+ (cond [(> (first a-lon) x) (first a-lon)] [ else 0]) acc ))])) "sumBig_fwd test cases:" (= 9 (sumBig_fwd myLON1 3)) (= 5 (sumBig_fwd myLON1 4)) (= 36 (sumBig_fwd myLON2 -2)) (= 33 (sumBig_fwd myLON2 2)) ;;------------- Alternative method #1 --------------------- ;; sumBig_fwd1: lon, num --> num ;; Sums all numbers in a list of numbers ;; larger than x (define (sumBig_fwd1 a-lon x) (cond [(empty? a-lon) 0] [(cons? a-lon) (sumBig_fwd_h a-lon x 0)])) "sumBig_fwd1 test cases:" (= 9 (sumBig_fwd1 myLON1 3)) (= 5 (sumBig_fwd1 myLON1 4)) (= 36 (sumBig_fwd1 myLON2 -2)) (= 33 (sumBig_fwd1 myLON2 2)) ;;------------- Alternative method #2 --------------------- ;; sumBig_fwd2: lon, num --> num ;; Sums all numbers in a list of numbers ;; larger than x (define (sumBig_fwd2 a-lon x) (sumBig_fwd_h a-lon x 0)) "sumBig_fwd2 test cases:" (= 9 (sumBig_fwd2 myLON1 3)) (= 5 (sumBig_fwd2 myLON1 4)) (= 36 (sumBig_fwd2 myLON2 -2)) (= 33 (sumBig_fwd2 myLON2 2))