Blame


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