What would be our focus ? Geometry deals with Declarative or “What is” knowledge. Computer Science deals with Imperative or “How to” knowledge 2/23/2019.

Slides:



Advertisements
Similar presentations
1 Programming Languages (CS 550) Lecture Summary Functional Programming and Operational Semantics for Scheme Jeremy R. Johnson.
Advertisements

Chapter 3 Functional Programming. Outline Introduction to functional programming Scheme: an untyped functional programming language.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 3: Rules of Evaluation.
Fall 2008Programming Development Techniques 1 Topic 2 Scheme and Procedures and Processes September 2008.
6.001 SICP SICP – September Processes, Substitution, Recusion, and Iteration Trevor Darrell 32-D web page:
מבוא מורחב 1 Lecture 3 Material in the textbook Sections to
מבוא מורחב - שיעור 2 1 Lecture 2 - Substitution Model (continued) - Recursion - Block structure and scope (if time permits)
Functional programming: LISP Originally developed for symbolic computing First interactive, interpreted language Dynamic typing: values have types, variables.
1 Extended Introduction to Computer Science 2 Administration סגל הקורס: –מרצים: ד"ר דניאל דויטש, איל כהן –מתרגלת:לבנת ג'רבי –בודק: ינון פלד Book: Structure.
Principles of Programming Languages Lecture 1 Slides by Yaron Gonen, based on slides by Daniel Deutch and lecture notes by Prof. Mira Balaban.
מבוא מורחב 1 Your turn (Review) What does a lambda expression return when it is evaluated? the value of a lambda expression is a procedure What three things.
Principles of Programming Languages Lecture 1 Slides by Daniel Deutch, based on lecture notes by Prof. Mira Balaban.
מבוא מורחב 1 Review: scheme language things that make up scheme programs: self-evaluating 23, "hello", #t names +, pi combinations (+ 2 3) (* pi 4) special.
COP4020 Programming Languages Functional Programming Prof. Xin Yuan.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 3: Rules of Evaluation.
1 The Evaluator. 2 Compiler vs. Interpreter Command Processing Unit The Computer Program in Low Level Machine Language Program in High Level Language.
PPL Applicative and Normal Form Verification, Type Checking and Inference.
Principles of Programming Languages Lecture 1 Slides by Yaron Gonen, based on slides by Daniel Deutch and lecture notes by Prof. Mira Balaban.
Basic Scheme February 8, 2007 Compound expressions Rules of evaluation Creating procedures by capturing common patterns.
What is the main focus of this course? This course is about Computer Science Geometry was once equally misunderstood. Term comes from ghia & metra or earth.
1 Lecture 14: Assignment and the Environment Model (EM)
1/32 This Lecture Substitution model An example using the substitution model Designing recursive procedures Designing iterative procedures Proving that.
1/33 Basic Scheme February 8, 2007 Compound expressions Rules of evaluation Creating procedures by capturing common patterns.
Lecture 3: Rules of Evaluation CS150: Computer Science
1 Topic #3: Lambda CSE 413, Autumn 2007 Programming Languages.
PPL Syntax & Formal Semantics Lecture Notes: Chapter 2.
CS314 – Section 5 Recitation 9
Operational Semantics of Scheme
Functional Programming
Basic Scheme February 8, 2007 Compound expressions Rules of evaluation
Propositional Calculus: Boolean Functions and Expressions
Lecture 4: Evaluation Rules Recursion CS200: Computer Science
6.001 SICP Variations on a Scheme
September 4, 1997 Programming Languages (CS 550) Lecture 6 Summary Operational Semantics of Scheme using Substitution Jeremy R. Johnson TexPoint fonts.
Original material by Eric Grimson
Class 19: Think Globally, Mutate Locally CS150: Computer Science
CS21b: Structure and Interpretation
6.001 SICP Data abstractions
Higher-Order Procedures
Your turn (Review) What does a lambda expression return when it is evaluated? the value of a lambda expression is a procedure What three things are in.
The Metacircular Evaluator
FP Foundations, Scheme In Text: Chapter 14.
Functional Programming
This Lecture Substitution model
CS220 Programming Principles
Dynamic Scoping Lazy Evaluation
The Metacircular Evaluator
Lecture #6 section pages pages72-77
Lecture #6 מבוא מורחב.
What would be our focus ? Geometry deals with Declarative or “What is” knowledge. Computer Science deals with Imperative or “How to” knowledge 12/25/2018.
Abstraction and Repetition
The Metacircular Evaluator (Continued)
6.001 SICP Further Variations on a Scheme
Extended Introduction to Computer Science
Streams, Delayed Evaluation and a Normal Order Interpreter
Lecture 13 - Assignment and the environments model Chapter 3
Material in the textbook Sections to 1.2.1
6.001 SICP Variations on a Scheme
6.001: Structure and Interpretation of Computer Programs
Today’s topics Abstractions Procedural Data
Lecture 2 מבוא מורחב.
This Lecture Substitution model
6.001 SICP Interpretation Parts of an interpreter
Lecture 3: Rules of Evaluation CS200: Computer Science
Introduction to the Lab
This Lecture Substitution model
Lecture 2 מבוא מורחב.
Good programming practices
Abstraction and Repetition
Lecture 25: The Metacircular Evaluator Eval Apply
Presentation transcript:

What would be our focus ? Geometry deals with Declarative or “What is” knowledge. Computer Science deals with Imperative or “How to” knowledge 2/23/2019 מבוא מורחב

Declarative Knowledge “What is true” knowledge 2/23/2019 מבוא מורחב

Imperative Knowledge “How to” knowledge To find an approximation of square root of x: Make a guess G Improve the guess by averaging G and x/G Keep improving the guess until it is good enough X = 2 G = 1 X/G = 2 G = ½ (1+ 2) = 1.5 X/G = 4/3 G = ½ (3/2 + 4/3) = 17/12 = 1.416666 X/G = 24/17 G = ½ (17/12 + 24/17) = 577/408 = 1.4142156 2/23/2019 מבוא מורחב

“How to” knowledge Process – series of specific, mechanical steps for deducing information, based on simpler data and set of operations Procedure – particular way of describing the steps a process will evolve through Need a language for description: vocabulary rules for connecting elements – syntax rules for assigning meaning to constructs – semantics Using language of procedures to solve problems 2/23/2019 מבוא מורחב

Scheme Basics Rules for Scheme Legal expressions have rules for constructing from simpler pieces (Almost) every expression has a value, which is “returned” when an expression is “evaluated”. Every value has a type. 2/23/2019 מבוא מורחב

Language Elements Primitives Means of combination Means of abstraction 2/23/2019 מבוא מורחב

Language elements -- primitives Numbers – self-evaluating rule 23  23 -36  -36 Names for built-in procedures +, *, /, -, =, … What is the value of such an expression? +  [#procedure …] Evaluating by looking up value associated with name 2/23/2019 מבוא מורחב

Language elements – combinations How do we create expressions using these procedures? (+ 2 3) Close paren Open paren Expression whose value is a procedure Other expressions Evaluate by getting values of subexpressions, then apply operator to values of arguments 2/23/2019 מבוא מורחב

Language elements - combinations Can use nested combinations – just apply rules recursively (+ (* 2 3) 4) 10 (* (+ 3 4) (- 8 2)) 42 2/23/2019 מבוא מורחב

Language elements -- abstractions In order to abstract an expression, need way to give it a name (define score 23) This is a special form Does not evaluate second expression Rather, it pairs that name with the value of the third expression in an environment Return value is unspecified 2/23/2019 מבוא מורחב

Language elements -- abstractions To get the value of a name, just look up pairing in environment score  23 Note that we already did this for +, *, … (define total (+ 12 13)) (* 100 (/ score total))  92 can create a complex thing, name it, treat it as primitive 2/23/2019 מבוא מורחב

Scheme Basics Rules for evaluation If self-evaluating, return value. If a name, return value associated with name in environment. If a special form, do something special. If a combination, then a. Evaluate all of the subexpressions of combination (in any order) b. apply the operator to the values of the operands (arguments) and return result 2/23/2019 מבוא מורחב

Capturing common patterns Here are some common patterns (* 5 5) (* 23 23) (* score score) (* x x) How do we generalize (e.g. the last expression)? 2/23/2019 מבוא מורחב

Language elements -- abstractions Need to capture ways of doing things – use procedures (lambda (x) (* x x)) parameters body To process something multiply it by itself Special form – creates a procedure and returns it as value 2/23/2019 מבוא מורחב

Language elements -- abstractions Use this anywhere you would use a proceduure ((lambda (x) (* x x)) 5) 2/23/2019 מבוא מורחב

Scheme Basics Rules for evaluation Rules for application If self-evaluating, return value. If a name, return value associated with name in environment. If a special form, do something special. If a combination, then a. Evaluate all of the subexpressionss of combination (in any order) b. apply the operator to the values of the operands (arguments) and return result Rules for application If procedure is primitive procedure, just do it. If procedure is a compound procedure, then: evaluate the body of the procedure with each formal parameter replaced by the corresponding actual argument value. 2/23/2019 מבוא מורחב

Language elements -- abstractions Use this anywhere you would use a proceduure ((lambda (x) (* x x)) 5) (* 5 5) 25 Can give it a name (define square (lambda (x) (* x x))) (square 5)  25 2/23/2019 מבוא מורחב

Taxonomy of Expressions Primitive Expressions Constants (self-evaluating) Numerals, e.g.17 == Sch-Num 7 Strings, e.g. “hello” == Sch-String hello Booleans, e.g. #f, #t == Sch-Bool Names E.g. + == primitive procedure E.g. x == variable created by define or procedure application Compound Expressions Combinations: (<operator> <operand> <operand> …) Special forms: Define: (define <name> <exp>) Lambda: (lambda (<formal1> <formal2> …) <body>) If: (if <predicate> <consequent> <alternative>) …. More to come 2/23/2019 מבוא מורחב