Blob


1 ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 ;; about the language level of this file in a form that our tools can easily process.
3 #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 ;A digit is an N >=0 and <=9.
6 to10 : (listof digits) -> number
8 Examples:
9 (= (to10 (list 1 0 2))
10 102)
12 (= (to10 (list 2 1))
13 21)
15 (define (to10 alod0)
16 (local ;; accu represents the accumulator
17 ((define (to10-accu alod1 accu)
18 (cond
19 [(empty? alod1) 0]
20 [else (first alod1) (rest alod1) accu])))
21 (to10-accu alod0 ...)))