G make_counter params: body: count = 0 def counter():... my_counter params: body: count += 1... E1 count0 counter E2E2.

Slides:



Advertisements
Similar presentations
G make_adder params: x body: def add_x(y):... Current frames: G.
Advertisements

G make_adder params: x body: def add_x(y):... Current frames: G.
And other languages….  Writing programs that write programs (cool!)  Often used to create domain-specific languages (DSL) You’ve all heard of at least.
Def f(n): if (n == 0): return else: print(“*”) return f(n-1) f(3)
Chapter 8. Operator Overloading Operator overloading gives the opportunity to redefine C++ Operator overloading refers to redefine C++ operators such.
Recursion in Scala. 2 Definitions A recursive method is a method that calls itself A method is indirectly recursive if it calls a method that calls a.
Study Guide. a. 1 of 2 numbers multiplied together to get a product b. The answer to a division problem c. The answer to a multiplication problem d. None.
Study Guide. a) PEMDAS b) Please Excuse My Dear Aunt Sally c) Parenthesis, Exponents, Multiplication and Division, Addition and Subtraction d) Both A.
University of British Columbia CPSC 111, Intro to Computation 2009W2: Jan-Apr 2010 Tamara Munzner 1 Loops III Lecture 20, Fri Mar
CS 117 Spring 2002 Review for Exam 2 March 6, 2002 open book, 1 page of notes.
Skip Counting Counting by 2, 5, and 10.
Facts about Square Roots. Facts about square roots.
Inheritance #1 First questions Similar to Python? What about visibility and encapsulation? – can an object of the child class access private members.
P: (d e) b 3 : (f e d) b2b2 E1E1 GE a:8 b:5 c:8 f: p: (x y) b 1 : (+ x y) a:8 b:5 c:3 GE 53 p: p: (a b c) b 2 : (let…) b3b3 E2E2 d:13 e:40 E 1 53 b1b1.
Divisors and Factors Section 2.3. Objectives Write a counting number as the product of two factors in all possible ways List all of the factors (divisors)
Time to Teach Presents Year 5 (National Numeracy Strategy) (Based on DFEE Sample Lessons)
CS61A Lecture 21 Scheme Jom Magrotker UC Berkeley EECS July 24, 2012.
Chapter 6: Iteration Part 1. To be able to program loops with the while, for, and do statements To avoid infinite loops and off-by-one errors To understand.
Box 1Box 4Box 3Box 2 Box 5Box 8Box 7Box 6 My Shadow Box.
Functional Programming in Scheme and Lisp.
Practice session #9: The environment model. Frame: A substitution from variables to values (i.e., every variable in a frame has a single value). Environment:
Adding Integers with Counters
Lesson 6-3 Example Example 2 Find the difference of –2 and –4. Use counters. 1.Write the subtraction expression. –2 – (–4)
Skip counting Let’s skip count by 3s to
Worktext p. 181 Worktext p ___ units × ___ units = ___ square units 1 6 units
CS61A Lecture 20 Object-Oriented Programming: Implementation Jom Magrotker UC Berkeley EECS July 23, 2012.
Lecture 4 Functions. 2 CodeCademy 4.a. 3 CodeCademy: comments.  As parameter of a function  Second way to introduce variables:  What do max, min,
Rhombus 1.Both pairs of opposite sides are parallel 2. Both pairs of opposite sides are congruent 3. Both pairs of opposite angles are congruent 4. Consecutive.
Perimeter & Area. Menu Definition of perimeter Practice perimeter Definition of area Practice area.
1 FUNCTIONS - I Chapter 5 ANIMATION. 2 3 Demos Demo of a simple value-returning function Demo of a void function Demo of a void function calling a value-
Quadrilaterals Lesson 11 – 5. Quadrilateral Def: a 4 sided polygon. or ‘ a figure with 4 sides and 4 angles’ **The SUM of the 4 angles must equal 360º**
CS61A Lecture Colleen Lewis. Clicker poll Do you feel comfortable posting questions to piazza? A)Yes with my classmates and instructors.
Functions with Arguments and Return Values, Oh My! CS303E: Elements of Computers and Programming.
Objective: Students will subtract integers using rules (11-4).
Model the following problem using algebra tiles: (x + 4)(x – 4) x + 4 x - 4 x2x2.
Methods Matthew Harrison. Overview ● There are five main aspects of methods... ● 1) Modifiers – public, private ● 2) Method Name ● 3) Parameters ● 4)
Decimals 10ths and 100ths.
Year 1 & 2 Parent Subtraction Workshop Thursday 26th January 2017
Numeracy Resources for KS1
My Picture Dictionary Comments and Future Considerations: Sentences T
Goal: use counters to add integers
3rd Grade Math Module 7 Lesson 8
Matchstick puzzles If I was to carry this pattern on so that there were 100 squares in a row, how many matchsticks would I need?
Using Lisp Lisp is a interactive system
Skip Counting Counting by 2, 5, and 10.
زبان بدن Body Language.
קורס פיננסי – מושגים פיננסיים / כלכליים
Repetition Statements
Skip Counting Counting by 2, 5, and 10.
Assignment 1.
Reflections Reflect the object in the x axis
Year 2 Autumn Term Week 8 Lesson 5
Hundreds board counting
To recall the doubles of all numbers to at least 10
Area of rectangle.
Standard deviation Spearman's Rank Correlation Chi squared test
Year 2 Autumn Term Week 8 Lesson 5
Counter Integrated Circuits (I.C.s)
Operations With Integers
Objective - To find the area of squares and rectangles.
Solve the equation: 6 x - 2 = 7 x + 7 Select the correct answer.
Test Automation For Web-Based Applications
Singleton Pattern Damian Gordon.
Year 5 (National Numeracy Strategy) (Based on DFEE Sample Lessons)
Coordinate Shirley Sides
MSG : SHOW WORK 277 PROBLEM 291.
Descriptive statistics Pearson’s correlation
Principles of Programming Languages
This is my sheet And this is my sheet.
Python Reserved Words Poster
Presentation transcript:

G make_counter params: body: count = 0 def counter():... my_counter params: body: count += 1... E1 count0 counter E2E2

G make_counter params: body: count = 0 def counter():... my_counter params: body: count += 1... E1 count0 counter E2E2 count?

G make_counter params: body: count = 0 def counter():... my_counter params: body: nonlocal count... E1 count0 1 2 counter E2E3

G make_counting_fn params: fn body: count = 0... E1 count0 params: x body: return x * x square params: arg body: nonlocal count... counting_fn counting_square fn

G make_counting_fn params: fn body: count = 0... E1 count0 1 2 params: x body: return x * x square params: arg body: nonlocal count... counting_fn counting_square fn E2 arg7 E3 x7 E5 x3 E4 arg3 sq_749 sq_39

G make_pair params: first, second body: def pair(msg):... E1 first1 pair params: msg body: if msg == ‘first’:... my_pair second2

G make_pair params: first, second body: def pair(msg):... E1 first1 pair params: msg body: if msg == ‘first’:... my_pair second2 E2 msg ‘first’ E3 msg ‘second’

G make_pair params: first, second body: def pair(msg, arg=None):... E1 first1 pair params: msg, arg=None body: nonlocal first, second... my_pair second2 E2 msg ‘first’ E4 msg ‘first’ E3 msg ‘set-first’ arg None arg None arg 5