interpreter-6

# interpreter-6 - RobotInterpreters CMSC 143 Keith OHara...

This preview shows pages 1–9. Sign up to view the full content.

Sep 20 2010 CMSC143 - O'Hara 1 CMSC 143 Robot Interpreters Keith O’Hara [email protected]

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Sep 20 2010 CMSC143 - O'Hara 2 Announcements Robot Behavior Lab due Today (20 th ) Team Performance due in a Week (27 th )
Sep 20 2010 CMSC143 - O'Hara 3 Quiz (matching) def b ( x ): if bool1(x): if bool2(x): z() def a ( x ): if bool1(x): z() if bool2(x): z() def one ( x ): if bool1(x) or bool2(x): z() def c ( x ): if bool1(x): pass else : z() def three ( x ): if bool1(x) and bool2(x): z() def two ( x ): if not bool1(x): z()

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Sep 20 2010 CMSC143 - O'Hara 4 Factorial Factorial Function 6! = 6 * 5 * 4 * 3 * 2 * 1 7! = 7 * 6 * 5 * 4 * 2 * 2 * 1 = 7 * 6! 9! = 9 * 8 * 7 * … * 2 * 1 10! = 10 * 9 * 8 * … * 2 * 1 = 10 * 9! 2! = 2 * 1 1! = 1 0! = 1
Sep 20 2010 CMSC143 - O'Hara 5 Factorial x! = x * (x-1)! # number should be greater than or equal to zero def factorial( number ): if number < 1: return 1 else: f = number *factorial( number - 1) return f factorial(4)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Sep 20 2010 CMSC143 - O'Hara 6 Tracing Factorial def factorial( number ): if number < 1: return 1 else: f = number *factorial( number - 1) return f factorial(4) Top-level factorial number = 4; f = 4 * ? factorial number = 3; f = 3 * ? factorial number = 2; f = 2 * ? factorial number = 1; f = 1 * ? factorial number = 0 number = 4; f = 4 * 6 number = 3; f = 3 * 2 number = 2; f = 2 * 1 number = 1; f = 1 * 1
Meta-programs Programs than input and output programs Compilers; Interpreters Interpret stream of text (python, lisp) or images (piet) Sep 20 2010 CMSC143 - O'Hara 7 http://www.dangermouse.net/esoteric/piet/piet_factorial_ big.png (defun factorial (n) (if (<= n 1) 1 (* n (factorial (- n 1))))) def factorial( number ): if number < 1: return 1 else: return number *factorial( number - 1)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Sep 20 2010 CMSC143 - O'Hara 8 A Python Robot Interpreter A program to control the robot using keyboard Give it a list of commands to execute f: forward b: backward
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 10/14/2010 for the course CMSC 143 taught by Professor Keitho'hara during the Spring '10 term at Bard College.

### Page1 / 23

interpreter-6 - RobotInterpreters CMSC 143 Keith OHara...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online