Download presentation
Presentation is loading. Please wait.
Published byCrystal Conley Modified over 9 years ago
1
Machaut Messe Performance Performance Performance Isorhythm Isorhythm
2
Review
3
Remember All Lisp expressions must have matched parentheses; that is, every open paren must appropriately have a closed paren. All Lisp expressions must have matched parentheses; that is, every open paren must appropriately have a closed paren. Document all of your work by placing comments after a “;” or enclosing in “”, or placing between #| this is documentation |# Document all of your work by placing comments after a “;” or enclosing in “”, or placing between #| this is documentation |# Name variables and everything you do such that later on you can tell what they mean and does. Name variables and everything you do such that later on you can tell what they mean and does.
4
Remember Readability is @#$%^&* everything Readability is @#$%^&* everything
5
One flew over the parentheses nest! One flew over the parentheses nest!
6
Hummmmmmm (+ (first *my-numbers*) (+ (first *my-numbers*) (third *my-numbers*) (third *my-numbers*) (first *my-numbers*)) (first *my-numbers*)) Note how much easier the above is to read than: (+ (first *my-numbers*)(third *my-numbers*)(first *my-numbers*)) (+ (first *my-numbers*)(third *my-numbers*)(first *my-numbers*)) 4
7
More exercises (nth 5 ‘(1 2 3 4 5 6)) (nth 5 ‘(1 2 3 4 5 6)) 6 Remember to check whether the primitive you’re using is zero or one based as in Remember to check whether the primitive you’re using is zero or one based as in (nthcdr 5 ‘(1 2 3 4 5 6)) (nthcdr 5 ‘(1 2 3 4 5 6)) 6 whew whew
8
More? (position 1 '(2 1 3 4 5)) (position 1 '(2 1 3 4 5)) 1 (position 2 '(2 1 3 4 5)) 0 And so on.
9
From (0 60 1000 1 64) get: From (0 60 1000 1 64) get: 1) 0 1) 0 2) 64 2) 64 3) 1000 3) 1000 4) (1000 1 64) 4) (1000 1 64) 5) (60 1000) 5) (60 1000) 6) (0 60 1000) 6) (0 60 1000) 7) (0 1) 7) (0 1) 8) ((0)) 8) ((0)) 9) (60 1000 64) 9) (60 1000 64) 10) (60 0) 10) (60 0)
10
From (((a) b) c) get: From (((a) b) c) get: 1) a 1) a 2) c 2) c 3) b 3) b 4) (a b) 4) (a b) 5) (a (b c))) 5) (a (b c)))
11
From (a b c d e) get: From (a b c d e) get: 1) (d e) 1) (d e) 2) 5 2) 5 3) (a (b (c (d (e))))) 3) (a (b (c (d (e))))) 4) (e d c b a) 4) (e d c b a) 5) (a b c d) 5) (a b c d)
12
From a get: From a get: 1) (a) 1) (a) 2) (a. a) 2) (a. a) 3) (a (a)) 3) (a (a)) 4) ((a) a) 4) ((a) a) 5) (a ()) 5) (a ())
13
From a and (b c) get: From a and (b c) get: 1) (a b c) 1) (a b c) 2) ((a) b c) 2) ((a) b c) 3) (a (b c)) 3) (a (b c)) 4) (a c) 4) (a c) 5) (c b a) 5) (c b a)
14
From (a b) and (c d) get: From (a b) and (c d) get: 1) (a b c d) 1) (a b c d) 2) ((a b) c d) 2) ((a b) c d) 3) ((a b)(c d)) 3) ((a b)(c d)) 4) (b a d c) 4) (b a d c) 5) (a (b c) d) 5) (a (b c) d)
15
(append '((1)) '(2 3)) (append '((1)) '(2 3))
16
((1) 2 3) ((1) 2 3)
17
(append '((2)(3)) '(4 5)) (append '((2)(3)) '(4 5))
18
((2) (3) 4 5) ((2) (3) 4 5)
19
(first '(((a)) (b c d e))) (first '(((a)) (b c d e)))
20
((A)) ((A))
21
(rest '(((((f)))))) (rest '(((((f))))))
22
nil nil
23
(first '(rest (a b c))) (first '(rest (a b c)))
24
rest rest
25
(first (second '(((1 2))(2 3 4)((5 6 7))))) (first (second '(((1 2))(2 3 4)((5 6 7)))))
26
2
27
(second (first '(((1 2))(2 3 4)((5 6 7))))) (second (first '(((1 2))(2 3 4)((5 6 7)))))
28
nil nil
29
Cope-event (0 60 1000 1 127) (0 60 1000 1 127) On-time (1000 per second) On-time (1000 per second) Pitch number (24 108) Pitch number (24 108) Duration (1000 per second) Duration (1000 per second) Channel (1-16) Channel (1-16) Loudness (1- 127) Loudness (1- 127)
30
Therefore (0 60 1000 1 127) (0 60 1000 1 127) Translates to Translates to A loud quarter-note middle C on channel 1 A loud quarter-note middle C on channel 1 Channel assignments are separate and (except for channel 10 usually) can produce any general MIDI sound Channel assignments are separate and (except for channel 10 usually) can produce any general MIDI sound When saved to MIDI file and opened in a notation program produces the above. When saved to MIDI file and opened in a notation program produces the above.
31
Cope-events ((0 60 1000 1 127)(1000 62 1000 1 127)(2000 64 1000 1 127)(3000 65 1000 1 127)(4000 67 1000 1 127)(5000 69 1000 1 127)(6000 71 1000 1 127)(7000 72 1000 1 127)) ((0 60 1000 1 127)(1000 62 1000 1 127)(2000 64 1000 1 127)(3000 65 1000 1 127)(4000 67 1000 1 127)(5000 69 1000 1 127)(6000 71 1000 1 127)(7000 72 1000 1 127)) Produces a loud C-major scale in quarter notes. Produces a loud C-major scale in quarter notes.
32
Some more functions + (can have any number of args) + (can have any number of args) - (can have any number of args) - (can have any number of args) / (can have any number of args) / (can have any number of args) * (can have any number of args) * (can have any number of args) sort (be careful) sort (be careful) exp exp sqrt sqrt sin, cosin, tan (etc.) sin, cosin, tan (etc.)
33
Predicates Some Lisp functions serve as test functions as in Some Lisp functions serve as test functions as in (listp 1) (listp 1) which returns nil because its argument is not a list which returns nil because its argument is not a list (atomp ‘(1)) (atomp ‘(1)) which returns nil because its argument is not an atom which returns nil because its argument is not an atom The suffix “p” stands for predicate The suffix “p” stands for predicate
34
Conditionals Some functions in Common Lisp—called conditionals—test data for certain attributes. Some functions in Common Lisp—called conditionals—test data for certain attributes. For example, the function if tests its first argument and returns its second argument if it proves true, or its third argument if it proves false. For example, the function if tests its first argument and returns its second argument if it proves true, or its third argument if it proves false.
35
Example ? (if (numberp 1) t nil) ? (if (numberp 1) t nil) Returns Returns T because “1” is a number and thus the first choice (t) is the result because “1” is a number and thus the first choice (t) is the result Note that Lisp is case insensitive. Note that Lisp is case insensitive.
36
Named This combination is often termed an if- then-else clause. This combination is often termed an if- then-else clause.
37
Quiz ? (if (numberp (second ‘(a 2 b d f)) ‘yes ‘no) ? (if (numberp (second ‘(a 2 b d f)) ‘yes ‘no) returns returns > yes > yes
38
Quiz ? (cons 1 (rest ‘(1 2 3 4 5))) ? (cons 1 (rest ‘(1 2 3 4 5))) returns returns > (1 2 3 4 5) > (1 2 3 4 5)Whew.
39
Now you think of some questions!
40
Let’s try for a few combinations (defvar *my-numbers* ‘(1 2 3)) (defvar *my-numbers* ‘(1 2 3)) (if (equal (first *my-numbers*) 2) (if (equal (first *my-numbers*) 2) (third *my-numbers*) (third *my-numbers*) (first *my-numbers*)) (first *my-numbers*)) What’s the answer?
41
Answer 1
42
Another (append (append (append *my-numbers* *my-numbers*) (append *my-numbers* *my-numbers*) (rest *my-numbers*)) (rest *my-numbers*))
43
Answer (1 2 3 1 2 3 2 3) (1 2 3 1 2 3 2 3)
44
A little harder (if *my-numbers* (last *my-numbers*) (if *my-numbers* (last *my-numbers*) ()) ())
45
Answer (3) (3) N.B. The function “last” returns a list of the last number. Weird, but true. N.B. The function “last” returns a list of the last number. Weird, but true.
46
Try this: (if (equal *my-numbers* (1 2 3)) (if (equal *my-numbers* (1 2 3)) (reverse *my-numbers*)) (reverse *my-numbers*))
47
Answer Error! (forget the single quote on data!!!) Error! (forget the single quote on data!!!)
48
Whew! (third ‘((((a)) b)(c ((d) e) f)(((g)) h I)) (third ‘((((a)) b)(c ((d) e) f)(((g)) h I))
49
Answer (((g)) h I)) (((g)) h I))
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.