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 |30.1|) (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 ;relative-2-absolute : (listof numbers) -> (listof numbers)
5 ;Convert alon into absolute distances. The first element is (first alon) away from the origin.
7 (define (relative-2-absolute alon)
8 (cond
9 [(empty? alon) empty]
10 [else (cons (first alon)
11 (add-to-each (first alon) (relative-2-absolute (rest alon))))]))
13 (define (add-to-each n alon)
14 (map (lambda (x) (+ n x)) alon))
16 ;On the order of N^2