```;                    Lisp and Randomness Toolkit (lrt.sal)

; Your first coding assignment is to implement a "toolbox" (a set of
; functions) for working with lists and randomness. The second half of
; this exercise assumes that you have read and practiced the material
; presented in loop.sal

; Directions: implement the function described at each TOOL:
; heading. Then use the associated TEST: statement to test out your
; function definition to make sure it works.

; TOOL: define the function jiggle(val, low, high) that adds to val a
; random amount between the specified low and high:

; TEST:

begin
with k = random(128)
print("keynum ", k, " jiggled is ", jiggle(k, -2, 3))
end

; define the function palinlist(list) that returns a palindrome
; created from the input list. example: palinlist({a b c}) => {a b c c
; b a}. Tip: use just two of the Top 10 list functions to do this.

; TEST:

palinlist({a b c})

; define the function palinlist2(list) that is like palinlist except
; that the palindrome it returns does NOT contain a direct repetition
; of the last element in the input list. Example: palinlist2({a b c})
; => {a b c b a}. Tip: You need to use an additional function from the
; Top 10 functions to do this.

palinlist2({a b c})

; define the function trichord(root, 3rd, 5th) that takes a key number
; root and two intervals and reutrns a list of key numbers
; representing a trichord. example: trichord(60, 6, 11) => {60 66 71}

trichord(random(128), 6, 11)

; TOOL: define the function rantriad(root) that calls trichord to
; construct either a major, minor, diminished or augmented triad based
; on a random choice. Tip: use a local variable to hold a randomly
; selected choice between the four differenet triads. use the 'if'
; statement to return the proper triad for each possible choice.

; TEST:

; TOOL: define the function rantrichord(root) that takes a root keynum
; and then uses the trichord function to return a randomly constructed
; trichord with the flowing characterisitcs: the first member of the
; trichord is the specified root.  the second memeber can be any
; keynum from root + 3 to root + 7 inclusive. the third member can be
; any keynum from root + 8 to root + 11 inclusive.

; TEST:

rantrichord(between(40, 80))

; and inverts the triad by returning a new triad where the first
; element has been transposed up 1 octave and appeards at the end of
; the list. Tip: use the var[index] notation to get access to the
; individual elements of the input tried list.

; TEST:

;
; Iteration Utilities
; THe remaining function definitions cover the material presented in
; loop.sal.
;

; TOOL: define the function addlist(list,amt) that inrements the
; elements of list by amt. example: inclist({60 62 63}, 12) => {72 74
; 75}.  Tip: use loop to iterate over the input list and set

; TOOL: define the function mullist(list,amt) that scales the elements
; in list by amt.

; TOOL: define the function jiglist(list, u, o) that calls jiggle to
; jiggle the elements in the input list.

; TOOL: define the function joinlists(lists) that takes a lists of
; lists and returns a single "flattened" list that is the concentation
; of the seperate lists. Example: joinlists({{a b} {c d} {e}) returns
; {a b c d e}. Tip: use a loop to iterate over each list in lists, the
; 'set' command has an operator that implmemnets list concatenation.

; TOOL: define a function ranseive (num, lb, ub, pcsieve) that returns a
; list of num nuber of random keynumbers between lb and ub whoes pitch
; classes are included int he list pcseive. In otherwords ransieve
; only collects keynumbers whose pcs are in the sieve.

```

Generated by sal2html 23 Aug 2007, 08:14:36