;; The first three lines of this file were inserted by DrScheme. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-beginner-abbr-reader.ss" "lang")((modname lect05b-tail-recur-example) (read-case-sensitive #t) (teachpacks ((lib "world.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "world.ss" "teachpack" "htdp"))))) (define (sum-all nums) (cond [(empty? nums) 0] [(cons? nums) (+ (first nums) (sum-all (rest nums)))])) ;(sum-all (list 1 99 2 98 3 97 4 96)) (define (sum-all-v2 nums) (help-sum nums 0)) (define (help-sum nums ssf) (cond [(empty? nums) ssf] [(cons? nums) (help-sum (rest nums) (+ (first nums) ssf))])) (sum-all-v2 (list 1 99 2 98 3 97 4 96))