Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "G make_counter params: body: count = 0 def counter():... my_counter params: body: count += 1... E1 count0 counter E2E2."— Presentation transcript:

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

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

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

4 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

5 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

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

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

8 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


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

Similar presentations


Ads by Google