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-beginner-reader.ss" "lang")((modname 13.0.3) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp")))))
4 12687dd9 2023-08-04 jrmu ;Data Definition
5 12687dd9 2023-08-04 jrmu ;A word is either
6 12687dd9 2023-08-04 jrmu ;1. an empty list or
7 12687dd9 2023-08-04 jrmu ;2. (cons l w) where l is a symbol (one of the
8 12687dd9 2023-08-04 jrmu ;lowercase letters 'a, 'b, ... 'z) and w is a word.
9 12687dd9 2023-08-04 jrmu ;
10 12687dd9 2023-08-04 jrmu Examples
11 12687dd9 2023-08-04 jrmu (cons 'h (cons 'i empty))
12 12687dd9 2023-08-04 jrmu (cons 'n (cons 'a (cons 'm (cons 'e empty))))
13 12687dd9 2023-08-04 jrmu
14 12687dd9 2023-08-04 jrmu A list-of-words is either
15 12687dd9 2023-08-04 jrmu 1. (cons w empty) or
16 12687dd9 2023-08-04 jrmu 2. (cons w low) where w is a word
17 12687dd9 2023-08-04 jrmu and low is a list-of-words.
18 12687dd9 2023-08-04 jrmu
19 12687dd9 2023-08-04 jrmu arrangements : word -> list-of-words
20 12687dd9 2023-08-04 jrmu Given a-word, return a list-of-words
21 12687dd9 2023-08-04 jrmu whose elements consist of words such
22 12687dd9 2023-08-04 jrmu that the list contains all
23 12687dd9 2023-08-04 jrmu the possible rearrangements (permutations)
24 12687dd9 2023-08-04 jrmu of the letters.
25 12687dd9 2023-08-04 jrmu
26 12687dd9 2023-08-04 jrmu (define (arrangements a-word)
27 12687dd9 2023-08-04 jrmu (cond
28 12687dd9 2023-08-04 jrmu [(empty? a-word) ...]
29 12687dd9 2023-08-04 jrmu []))
30 12687dd9 2023-08-04 jrmu