1 12687dd9 2023-08-04 jrmu ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 12687dd9 2023-08-04 jrmu ;; about the language level of this file in a form that our tools can easily process.
3 12687dd9 2023-08-04 jrmu #reader(lib "htdp-advanced-reader.ss" "lang")((modname |31.3|) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #t #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp")))))
4 12687dd9 2023-08-04 jrmu ;A digit is an N >=0 and <=9.
6 12687dd9 2023-08-04 jrmu to10 : (listof digits) -> number
9 12687dd9 2023-08-04 jrmu (= (to10 (list 1 0 2))
12 12687dd9 2023-08-04 jrmu (= (to10 (list 2 1))
15 12687dd9 2023-08-04 jrmu (define (to10 alod0)
16 12687dd9 2023-08-04 jrmu (local ;; accu represents the accumulator
17 12687dd9 2023-08-04 jrmu ((define (to10-accu alod1 accu)
19 12687dd9 2023-08-04 jrmu [(empty? alod1) 0]
20 12687dd9 2023-08-04 jrmu [else (first alod1) (rest alod1) accu])))
21 12687dd9 2023-08-04 jrmu (to10-accu alod0 ...)))