(define (f x) (if (< x 0) (lambda (y) (- y x)) (lambda (y) (- x y)))) GE f: P1 para:x body:(if … )

Slides:



Advertisements
Similar presentations
1 Lecture 16: Tables and OOP. 2 Tables -- get and put.
Advertisements

Resolving against moved files The setup: we have foo open for edit and want to submit, but it has been renamed, first to bar and then to ola. We need to.
Chapter 5: Objects and Classes class Point(Object): def __init__(x, y): self.x = initx self.y = inity def move(dx, dy): x += dx; y += dy; p = Point(10,
Variables, Environments and Closures. Overview We will Touch on the notions of variable extent and scope Introduce the notions of lexical scope and.
Shell Programming Oleh: Idris Winarno. Topik Hello world!!! Variables Functions Conditionals Loops Function.
מבוא מורחב למדעי המחשב בשפת Scheme תרגול 10. Environment Model 3.2, pages
מבוא מורחב למדעי המחשב בשפת Scheme תרגול 8. Environment Model 3.2, pages
1 Scheme Scheme is a functional language. Scheme is based on lambda calculus. lambda abstraction = function definition In Scheme, a function is defined.
6.001 SICP SICP – October environment Trevor Darrell 32-D512 Office Hour: W web page:
SICP Variations on a Scheme Scheme Evaluator – A Grand Tour Techniques for language design: Interpretation: eval/apply Semantics vs. syntax Syntactic.
Hand Evals in DrRacket Hand evaluation helps you learn how Racket reduces programs to values.
( (lambda (z) (define x (lambda (x) (lambda (y z) (y x)))) ( ( (x (lambda () z)) (lambda (z) z) 3 ) ) ) 2)
1 Scheme Although Scheme is syntactically a simple language, it supports sophisticated modeling: higher-order functions are a powerful tool in describing.
Fall 2008Programming Development Techniques 1 Topic 18 Environment Model of Evaluation Section 3.2 Acknowledgement: This lecture (and also much of the.
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.
Functional Programming in Scheme and Lisp. Overview In a functional programming language, functions are first class objects. You can create them, put.
Functional Programming and Lisp. Overview In a functional programming language, functions are first class objects. In a functional programming language,
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:
Training begins in… 15:00 minutes Training begins in… 14:00 minutes.
UMBC CMSC Common Lisp II. UMBC CMSC Input and Output Print is the most primitive output function > (print (list 'foo 'bar)) (FOO BAR) The.
1 Read-Eval-Print Loop (define (driver-loop) (prompt-for-input input-prompt) (let ((input (read))) (let ((output (eval input the-global-env))) (announce-output.
6.001 SICP 1/ SICP Object Oriented Programming Data Abstraction using Procedures with State Message-Passing Object Oriented Modeling Class diagrams.
1 Lecture 14: Assignment and the Environment Model (EM)
Bank Account Environment Model Examples Prof. Tony White April 2010.
SICP Object Oriented Programming Data Abstraction using Procedures with State Message-Passing Object Oriented Modeling Class diagrams Instance.
1 Lecture 19 Dynamic Scoping Lazy Evaluation (4.2.1, 4.2.2)
(define (prod lst) (let ((p 1)) loop: (when (null? l) (goto out:)) (set! p (* p (head lst))) (set! lst (tail lst)) (when (zero? p) (goto out:)) (goto loop:)
PS4 #6: if you got points off because you didn’t do an intersect with accessible and the start states, submit a re- grade. Today: let, let*, letrec in.
Message Passing: Alternative to Generics data is “active” — knows how to compute dispatch on operation (define (rat (n ) (d )) (method ((op )) (cond ((=
Haskell Chapter 5, Part II. Topics  Review/More Higher Order Functions  Lambda functions  Folds.
Graphing Greatest Integer Functions
Evaluating Expressions. S.W.B.A.T  Use the order of operations to evaluate expressions with variables and expressions with numbers.
(define (make-dining-philosophers n get-forks) (let* ((forks (build-vector n (lambda (i) (make-semaphore 1)))) (philosopher (lambda (i j) (letrec ((f (lambda.
1 Topic #3: Lambda CSE 413, Autumn 2007 Programming Languages.
Environment Model Examples Prof. Tony White April 2010 Ref:
PPL Lecture 4 Slides by Yaron Gonen, based on slides by Daniel Deutch and lecture notes by Prof. Mira Balaban.
Signs A Girl Likes You: Let’s Try To Read Her Mind Scoopify.
Environments and the Contour Model
Functions CSC 358/
6.001 SICP Object Oriented Programming
Variables, Environments and Closures
The role of abstractions
Env. Model Implementation
Lisp naturally embedded in Ruby
Original material by Eric Grimson
زبان بدن Body Language.
Use Part 1 of the Fundamental Theorem of Calculus to find the derivative of the function. {image}
Variables, Environments and Closures
إستراتيجيات ونماذج التقويم
Performance Evaluation
Lecture 15: Tables and OOP
Create and distinguish different types of graphs.
Name: _________________ Class: ________
Dynamic Scoping Lazy Evaluation
The Metacircular Evaluator
And more store-passing interpreters
Objective evaluate powers that have negative and zero exponents.
10:00.
Lecture 16: Tables and OOP
Bindings, Scope, and Extent
3.4 Local Binding Recall Scheme's let: > (let ((x 5)‏ (y 6))
Dividing a Whole Number by a fraction
Evaluate the limit: {image} Choose the correct answer from the following:
Which graph should I use?
6.001 SICP Variations on a Scheme
Order of Operations PowerPoint
Lecture 13: Assignment and the Environment Model (EM)
Fabric 1.2 Chaincode namespace _foo_f1_ _foo_f2_ _foo_f3_ _bar_b1_
Common Lisp II.
Evaluate the integral {image}
Presentation transcript:

(define (f x) (if (< x 0) (lambda (y) (- y x)) (lambda (y) (- x y)))) GE f: P1 para:x body:(if … )

(define (foo bar x y) (let ((g (bar y))) (+ (g x) (g y)))) (define (f x) (if (< x 0) (lambda (y) (- y x)) (lambda (y) (- x y)))) GE f:foo: P1P2 para:x body:(if … ) para:bar,x,y body:(let … )

(define (foo bar x y) (let ((g (bar y))) (+ (g x) (g y)))) (define (f x) (if (< x 0) (lambda (y) (- y x)) (lambda (y) (- x y)))) (foo f 1 -2) GE f:foo: P1P2 para:x body:(if … ) para:bar,x,y body:(let … ) bar:P1 x:1 y:-2

(define (foo bar x y) (let ((g (bar y))) (+ (g x) (g y)))) (define (f x) (if (< x 0) (lambda (y) (- y x)) (lambda (y) (- x y)))) (foo f 1 -2) GE f:foo: P1P2 para:x body:(if … ) para:bar,x,y body:(let … ) bar:P1 x:1 y:-2 Evaluating: (bar y) => (P1 -2)

(define (foo bar x y) (let ((g (bar y))) (+ (g x) (g y)))) (define (f x) (if (< x 0) (lambda (y) (- y x)) (lambda (y) (- x y)))) (foo f 1 -2) GE f:foo: P1P2 para:x body:(if … ) para:bar,x,y body:(let … ) bar:P1 x:1 y:-2 x:-2 Evaluating: (bar y) => (P1 -2)

(define (foo bar x y) (let ((g (bar y))) (+ (g x) (g y)))) (define (f x) (if (< x 0) (lambda (y) (- y x)) (lambda (y) (- x y)))) (foo f 1 -2) GE f:foo: P1P2 para:x body:(if … ) para:bar,x,y body:(let … ) bar:P1 x:1 y:-2 x:-2 Evaluating: (if (< x 0) … )

(define (foo bar x y) (let ((g (bar y))) (+ (g x) (g y)))) (define (f x) (if (< x 0) (lambda (y) (- y x)) (lambda (y) (- x y)))) (foo f 1 -2) GE f:foo: P1P2 para:x body:(if … ) para:bar,x,y body:(let … ) bar:P1 x:1 y:-2 x:-2 P3 para:y body:(- y x)

(define (foo bar x y) (let ((g (bar y))) (+ (g x) (g y)))) (define (f x) (if (< x 0) (lambda (y) (- y x)) (lambda (y) (- x y)))) (foo f 1 -2) GE f:foo: P1P2 para:x body:(if … ) para:bar,x,y body:(let … ) bar:P1 x:1 y:-2 g: x:-2 P3 para:y body:(- y x)

(define (foo bar x y) (let ((g (bar y))) (+ (g x) (g y)))) (define (f x) (if (< x 0) (lambda (y) (- y x)) (lambda (y) (- x y)))) (foo f 1 -2) GE f:foo: P1P2 para:x body:(if … ) para:bar,x,y body:(let … ) bar:P1 x:1 y:-2 g: x:-2 P3 para:y body:(- y x) Evaluating: (g x) => (P3 1)

(define (foo bar x y) (let ((g (bar y))) (+ (g x) (g y)))) (define (f x) (if (< x 0) (lambda (y) (- y x)) (lambda (y) (- x y)))) (foo f 1 -2) GE f:foo: P1P2 para:x body:(if … ) para:bar,x,y body:(let … ) bar:P1 x:1 y:-2 g: x:-2 P3 para:y body:(- y x) y:1 Evaluating: (- y x) => 3

(define (foo bar x y) (let ((g (bar y))) (+ (g x) (g y)))) (define (f x) (if (< x 0) (lambda (y) (- y x)) (lambda (y) (- x y)))) (foo f 1 -2) GE f:foo: P1P2 para:x body:(if … ) para:bar,x,y body:(let … ) bar:P1 x:1 y:-2 g: x:-2 P3 para:y body:(- y x) y:1 Evaluating: (g y) => (P3 -2)

(define (foo bar x y) (let ((g (bar y))) (+ (g x) (g y)))) (define (f x) (if (< x 0) (lambda (y) (- y x)) (lambda (y) (- x y)))) (foo f 1 -2) GE f:foo: P1P2 para:x body:(if … ) para:bar,x,y body:(let … ) bar:P1 x:1 y:-2 g: x:-2 P3 para:y body:(- y x) y:1 y:-2 Evaluating: (- y x) => 0

(define (foo bar x y) (let ((g (bar y))) (+ (g x) (g y)))) (define (f x) (if (< x 0) (lambda (y) (- y x)) (lambda (y) (- x y)))) (foo f 1 -2) GE f:foo: P1P2 para:x body:(if … ) para:bar,x,y body:(let … ) bar:P1 x:1 y:-2 g: x:-2 P3 para:y body:(- y x) y:1 y:-2 Evaluating: (+ 3 0) => 3