Machaut Messe Performance Performance Performance Isorhythm Isorhythm.

Slides:



Advertisements
Similar presentations
Solving Quadratic Equations Using the Zero Product Property
Advertisements

CS 63 LISP Philip Greenspun's Tenth* Rule of Programming:
ANSI Common Lisp 3. Lists 20 June Lists Conses List Functions Trees Sets Stacks Dotted Lists Assoc-lists.
Messiaen Quartet for the end of time And another.
Lisp. Versions of LISP Lisp is an old language with many variants Lisp is alive and well today Most modern versions are based on Common Lisp LispWorks.
11/10/04 AIPP Lecture 6: Built-in Predicates1 Combining Lists & Built-in Predicates Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture.
Lists in Lisp and Scheme a. Lists are Lisp’s fundamental data structures, but there are others – Arrays, characters, strings, etc. – Common Lisp has moved.
1 Programming Languages and Paradigms Lisp Programming.
Lambda Calculus and Lisp PZ03J. Lambda Calculus The lambda calculus is a model for functional programming like Turing machines are models for imperative.
LISP Programming. LISP – simple and powerful mid-1950’s by John McCarthy at M.I.T. “ LIS t P rocessing language” Artificial Intelligence programs LISP.
Exponents and Scientific Notation.
Lisp Fundamentals. Lisp a malformed acronym for List Processing designed to create computer programs first implemented in the late 1950s by John McCarthy.
Lisp – Introduction יעל נצר מערכות נבונות סמסטר ב' תשס"ו.
Defining functions in lisp In lisp, all programming is in terms of functions A function is something which –takes some arguments as input –does some computing.
Commands and predicates LISP functions are divided into 2 classes. Predicates are functions that return boolean values i.e. t or nil. The rest are commands.
Lisp. Versions of LISP Lisp is an old language with many variants –LISP is an acronym for List Processing language Lisp is alive and well today Most modern.
First Lecture on Introductory Lisp Yun Peng. Why Lisp? Because it’s the most widely used AI programming language Because AI researchers and theoreticians.
CS 330 Programming Languages 11 / 20 / 2007 Instructor: Michael Eckmann.
CMSC 471 LISP. Why Lisp? Because it’s the most widely used AI programming language Because it’s good for writing production software (Graham article)
Introductory Lisp Programming Lecture # 2 Main Topics –Basic Lisp data types –Lisp primitives –Details of list handling Cons cells (boxes) & their representation.
Artificial Intelligence and Lisp Lecture 6 LiU Course TDDC65 Autumn Semester, 2010
Thirteen conditional expressions: letting programs make “decisions”
LISP A brief overview. Lisp stands for “LISt Process” –Invented by John McCarthy (1958) –Simple data structure (atoms and lists) –Heavy use of recursion.
COMP 205 – Week 11 Dr. Chunbo Chu. Intro Lisp stands for “LISt Process” Invented by John McCarthy (1958) Simple data structure (atoms and lists) Heavy.
(5.1) COEN Functional Languages  Functional programming basics  Atoms and lists; cons  Useful primitive functions  Predicates  Arithmetic functions.
LISP 1.5 and beyond A very quick tour. Data Atoms (symbols) including numbers – All types of numbers including Roman! (well, in the early days) – Syntactically.
Lisp: a history Developed by John McCarthy in the 1950’s. Developed by John McCarthy in the 1950’s. Only Fortran has higher “seniority” Only Fortran has.
Use Cope-events which are like ( ) where element 1. is ontime in 1000s of second 2. is midi note (60 = middle C) 3. is duration in 1000s of.
PRACTICAL COMMON LISP Peter Seibel 1.
CSE S. Tanimoto Lisp Lisp S-Expressions: ATOMs Every Lisp object is either an ATOM or a CONS Symbols and numbers are kinds of atoms: X, APPLE,
Mitthögskolan 10/8/ Common Lisp LISTS. Mitthögskolan 10/8/2015 2Lists n Lists are one of the fundamental data structures in Lisp. n However, it.
1 Lists in Lisp and Scheme. 2 Lists are Lisp’s fundamental data structures. Lists are Lisp’s fundamental data structures. However, it is not the only.
Basic Lisp CIS 479/579 Bruce R. Maxim UM-Dearborn.
For Monday Read Chapter 3 Homework: –Lisp handout 2.
1 Lisp Functions –Built-in functions –Defining functions –Function Evaluation and Special Forms defun, if Control statements –Conditional if, cond –Repetition.
Function Design in LISP. Program Files n LISP programs are plain text –DOS extensions vary; use.lsp for this course n (load “filename.lsp”) n Can use.
Introduction to ACL2 CS 680 Formal Methods for Computer Verification Jeremy Johnson Drexel University.
Predicates, Functions and Files "I suppose I should learn Lisp, but it seems so foreign." - Paul Graham, Nov 1983.
Programming in Lisp; Instructor: Alok Mehta Programming in Lisp Introduction to Lisp.
LISP Data Types Functional Programming Academic Year Alessandro Cimatti
Building user-defined functions: the progressive envelopment technique The idea: define combinations of LISP primitives through a sequence of experiments.
Introduction to LISP. Lisp Extensible: It lets you define new operators yourself Lisp programs are expressed as lisp data structures –You can write programs.
Final Projects Some simple ideas. Composition (1) program that "learns" some aspect of musical composition.
Control in LISP More on Predicates & Conditionals.
Introduction to Objective Caml. General comments ML is a purely functional language--there are (almost) no side effects There are two basic dialects of.
Introduction to LISP Atoms, Lists Math. LISP n LISt Processing n Function model –Program = function definition –Give arguments –Returns values n Mathematical.
CSE S. Tanimoto Lisps's Basic Functionality 1 LISP: Basic Functionality S-expressions Conses Lists Predicates Evaluation and quoting Conditional.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
1 Outline Review Introduction to LISP Symbols and Numbers Lists Writing LISP Functions LISPWorks.
Artificial Intelligence and Lisp Lecture 6 LiU Course TDDC65 Autumn Semester,
More on the Selection Structure
Section 15.4, 15.6 plus other materials
Lisp S-Expressions: ATOMs
Modern Programming Languages Lecture 20 Fakhar Lodhi
Lists in Lisp and Scheme
LISP A brief overview.
First Lecture on Introductory Lisp
J.E. Spragg Mitthögskolan 1997
Modern Programming Languages Lecture 21 Fakhar Lodhi
Scheme: Basic Functionality
LISP A brief overview.
Lisp: Representation of Data
LISP: Basic Functionality
Modern Programming Languages Lecture 18 Fakhar Lodhi
LISP: Basic Functionality
LISP: Basic Functionality
Lisp.
Lisp: Representation of Data
LISP primitives on sequences
Lists in Lisp and Scheme
Presentation transcript:

Machaut Messe Performance Performance Performance Isorhythm Isorhythm

Review

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.

Remember Readability everything Readability everything

One flew over the parentheses nest! One flew over the parentheses nest!

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

More exercises (nth 5 ‘( )) (nth 5 ‘( )) 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 ‘( )) (nthcdr 5 ‘( )) 6 whew whew

More? (position 1 '( )) (position 1 '( )) 1 (position 2 '( )) 0 And so on.

From ( ) get: From ( ) get: 1) 0 1) 0 2) 64 2) 64 3) ) ) ( ) 4) ( ) 5) ( ) 5) ( ) 6) ( ) 6) ( ) 7) (0 1) 7) (0 1) 8) ((0)) 8) ((0)) 9) ( ) 9) ( ) 10) (60 0) 10) (60 0)

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)))

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)

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 ())

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)

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)

(append '((1)) '(2 3)) (append '((1)) '(2 3))

((1) 2 3) ((1) 2 3)

(append '((2)(3)) '(4 5)) (append '((2)(3)) '(4 5))

((2) (3) 4 5) ((2) (3) 4 5)

(first '(((a)) (b c d e))) (first '(((a)) (b c d e)))

((A)) ((A))

(rest '(((((f)))))) (rest '(((((f))))))

nil nil

(first '(rest (a b c))) (first '(rest (a b c)))

rest rest

(first (second '(((1 2))(2 3 4)((5 6 7))))) (first (second '(((1 2))(2 3 4)((5 6 7)))))

2

(second (first '(((1 2))(2 3 4)((5 6 7))))) (second (first '(((1 2))(2 3 4)((5 6 7)))))

nil nil

Cope-event ( ) ( ) 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)

Therefore ( ) ( ) 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.

Cope-events (( )( )( )( )( )( )( )( )) (( )( )( )( )( )( )( )( )) Produces a loud C-major scale in quarter notes. Produces a loud C-major scale in quarter notes.

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.)

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

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.

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.

Named This combination is often termed an if- then-else clause. This combination is often termed an if- then-else clause.

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

Quiz ? (cons 1 (rest ‘( ))) ? (cons 1 (rest ‘( ))) returns returns > ( ) > ( )Whew.

Now you think of some questions!

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?

Answer 1

Another (append (append (append *my-numbers* *my-numbers*) (append *my-numbers* *my-numbers*) (rest *my-numbers*)) (rest *my-numbers*))

Answer ( ) ( )

A little harder (if *my-numbers* (last *my-numbers*) (if *my-numbers* (last *my-numbers*) ()) ())

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.

Try this: (if (equal *my-numbers* (1 2 3)) (if (equal *my-numbers* (1 2 3)) (reverse *my-numbers*)) (reverse *my-numbers*))

Answer Error! (forget the single quote on data!!!) Error! (forget the single quote on data!!!)

Whew! (third ‘((((a)) b)(c ((d) e) f)(((g)) h I)) (third ‘((((a)) b)(c ((d) e) f)(((g)) h I))

Answer (((g)) h I)) (((g)) h I))