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-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 ;Data Definition
5 ;A word is either
6 ;1. an empty list or
7 ;2. (cons l w) where l is a symbol (one of the
8 ;lowercase letters 'a, 'b, ... 'z) and w is a word.
9 ;
10 Examples
11 (cons 'h (cons 'i empty))
12 (cons 'n (cons 'a (cons 'm (cons 'e empty))))
14 A list-of-words is either
15 1. (cons w empty) or
16 2. (cons w low) where w is a word
17 and low is a list-of-words.
19 arrangements : word -> list-of-words
20 Given a-word, return a list-of-words
21 whose elements consist of words such
22 that the list contains all
23 the possible rearrangements (permutations)
24 of the letters.
26 (define (arrangements a-word)
27 (cond
28 [(empty? a-word) ...]
29 []))