interpreter-6

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

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

View Full Document Right Arrow Icon
Sep 20 2010 CMSC143 - O'Hara 1 CMSC 143 Robot Interpreters Keith O’Hara kohara@bard.edu
Background image of page 1

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

View Full DocumentRight Arrow Icon
Sep 20 2010 CMSC143 - O'Hara 2 Announcements Robot Behavior Lab due Today (20 th ) Team Performance due in a Week (27 th )
Background image of page 2
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()
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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)
Background image of page 5

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

View Full DocumentRight Arrow Icon
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
Background image of page 6
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)
Background image of page 7

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

View Full DocumentRight Arrow Icon
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
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online