Administrivia Make sure you have completed the Mid Semester Survey –Scheduled the week before Spring Break –this will be worth some points Reading is.

Slides:



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

CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 17: HOF and Tick-Tack-Toe.
CS3 Fall 2005 Lecture 11: Finish higher order functions Midterm Prep.
Slide 1 CS3: Lecture 8 Advanced recursion. Slide 2 Schedule Oct 10Advanced recursion Oct 17Number-spelling Miniproject Oct 24Higher order procedures Oct.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 18: HOF.
Slide 1 CS3 Week 8: Recursion. Slide 2 Midterm 1 You did great If you need a re- grade, see the person that graded that question Solutions are available.
Slide 1. Slide 2 Administrivia Mid-semester survey this week (Thur/Fri) –you NEED to do this. Interviews should be starting in a few weeks. I apologize.
CS3 Fall 2005 Lecture 10: More on higher order functions.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 12: Homework stuff and Accumulating Recursion.
6.001 SICP SICP – September Processes, Substitution, Recusion, and Iteration Trevor Darrell 32-D web page:
Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 19: HOF Problems.
Sub Programs To Solve a Problem, First Make It Simpler.
CS3: Introduction to Symbolic Programming Spring 2006Nate Titterton Lecture 4: "Difference Between Dates" and data abstraction.
Slide 1 Midterm 1 Midterm 1: Feb 28 th (next week). –In the lecture slot, plus 20 minutes (4:10-5:30 pm, 120 Latimer) –Everything we’ve covered, including.
Data Abstraction… The truth comes out…. What we’re doing today… Abstraction ADT: Dotted Pair ADT: List Box and Pointer List Recursion Deep List Recursion.
Slide 1. Slide 2 Midterm 1 You did great If you need a regrade, see the person that graded that question Solutions available on the portal soon.
CS 330 Programming Languages 11 / 18 / 2008 Instructor: Michael Eckmann.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 11: Accumulating Recursion.
Feb 28More complicated recursions March 7Tree recursion, etc. Number-spelling Miniproject (#2) March 14Higher order procedures March 21Spring Break March.
Slide 1 Announcements Nate's office hours: –Monday, 12-2 –329 Soda Card key issues? (I've been told that any requests made before September 1 st didn't.
CS3: Introduction to Symbolic Programming Spring 2006Nate Titterton Lecture 2: Introduction, and Conditionals.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 8: Recursion.
Midterm Logistics Where? 4 Leconte ( When? Monday, 4:10 to 5:40 What to do? –“Review problems”
SUNY Morrisville-Norwich Campus-Week 12 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 9: Recursion Rocks!
Midterm Logistics Where? 2050 VLSB When? Monday, 4:10 to 5:40 What to do? –“Review problems” from Thursday/Friday in UCWise. –Two practice exams and solutions.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 16: Let and Lambda.
Slide 1 CS3 Fall 2005 Lecture 9: Higher Order Functions.
Quiz: Box and Pointer fun! (cons (cons (cons ‘hey (cons ‘there nil)) nil) (cons ‘wow nil)) (list ‘boo (append (list ‘hoo ‘hoo) (cons ‘see ‘me)))
CS3 Fall 2005 Lecture week 15. Administrivia The final survey will be up tomorrow: –you NEED to do this to receive a grade on your project! Final: –Saturday,
Administrivia Interviews this week: ex-TA Paul Hale Nate's office hours, as usual: Wed 2-4 The final survey will be up by Thursday: –you NEED to do this,
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 15: Procedures as Arguments.
Slide 1. Slide 2 Administrivia Nate's office hours are Wed, 2-4, in 329 Soda! TA Clint will be handing out a paper survey in class sometime this week.
1 Session-13 CSIT 121 Spring 2006 Test-1 is on March 9 th ; Demo-5 due date extended to March 7 Test-1 is on March 9 th ; Demo-5 due date extended to.
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.
CS 603: Programming Language Organization Lecture 10 Spring 2004 Department of Computer Science University of Alabama Joel Jones.
Solving Investment Problems. Investment Problems Investment problems have three parts: 1.The principal – the amount being invested 2.The rate – the %
Basic Scheme February 8, 2007 Compound expressions Rules of evaluation Creating procedures by capturing common patterns.
1 Week 5 Questions / Concerns What’s due: Lab2 part a due on Sunday Lab1 check-off by appointment Test#1 HW#5 next Thursday Coming up: Lab3 Posted. Discuss.
Spring 2008Programming Development Techniques 1 Topic 5.5 Higher Order Procedures (This goes back and picks up section 1.3 and then sections in Chapter.
07/10/04 AIPP Lecture 5: List Processing1 List Processing Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 5 07/10/04.
CS 152: Programming Language Paradigms April 7 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak
Solving Your Problem by Generalization CS 5010 Program Design Paradigms “Bootcamp” Lesson © Mitchell Wand, This work is licensed under.
CS61A Lecture Colleen Lewis. Clicker Test Are you coming to the potluck on Thursday on the 4 th floor of Soda from 6:30pm-9:00? A)Yes B)Maybe.
Warm ups. Return Quizzes Let’s go over them!! 9-8 Special Products Objective: To identify and expand the three special products.
CS3: Introduction to Symbolic Programming Spring 2006Nate Titterton Lecture 2: Introduction, and Conditionals.
TEACHING STUDENTS WITH SPECIAL NEEDS James Shinto CAS 310 Tuesdays 10:00 am.
Science Journals An introduction to Science Journals.
Lecture 4: Evaluation Rules Recursion CS200: Computer Science
PPL Lecture Notes: Chapter 3 High-Order Procedures Revisited.
September 4, 1997 Programming Languages (CS 550) Lecture 6 Summary Operational Semantics of Scheme using Substitution Jeremy R. Johnson TexPoint fonts.
Expanded Recursive Diagrams OCAML rapid tour, day 2
How Animals Grow Grammar.
تعارف. تعارف قواعد العمل ا الموبيل المشروبات الاحاديث الجانبية الاسئلة نفكر.
DIVIDING FRACTIONS TIC-TAC-TOE
Solving Your Problem by Generalization
Lecture #8 מבוא מורחב.
Announcements & review
Functional interface.
Lecture 5 Higher-order procedures מבוא מורחב - שיעור 5.
Announcements Nate’s office hours Card key problems?
Reading: ‘Washington, DC’
Lecture #7 מבוא מורחב.
READY READER Accumulate 5 points..
Lecture 3: Rules of Evaluation CS200: Computer Science
ormap, andmap, and filter
Introduction to the Lab
CS 403: Programming Languages
Presentation transcript:

Administrivia Make sure you have completed the Mid Semester Survey –Scheduled the week before Spring Break –this will be worth some points Reading is important for this week: –Tic-tac-toe, chapter 10 in SS –Case study: change-making

March 14Higher order procedures March 21Spring Break March 28Tic-Tac-Toe – read SS chapter 10! Case Study: Making Change (tree-recursion) – in the reader! April 4Elections mini-project (#3) April 11Midterm #2 (during lecture) Extending sentences, words to lists (in lab) April 18Advanced list processing (recursion) Start on the big project April 25Work on the big project (check-off 1, 2) May 2Big project (check-off 3) May 9Big Project due!

Tic Tac Toe

Higher order function (HOFs) A HOF is a procedure that takes a procedure as an argument. There are three main ones that work with words and sentences: –every – do something to each element –keep – return only certain elements –accumulate – combine the elements

(define (square-all sent) (if (empty? sent) ‘() (se (square (first sent)) (square-all (bf sent)) )) (square-all ‘( )) (every square ‘( ))

Write "my-keep" (my-keep odd? '( ))  (1 3 5)

Which HOFs would you use to write these? 1)capitalize-proper-names (c-p-n '(mr. smith goes to washington))  (mr. Smith goes to Washington) 2)count-if (count-if odd? '( ))  3 3)longest-word (longest-word '(I had fun on spring break))  spring 4)count-vowels-in-each (c-e-l '(I have forgotten everything))  ( ) 5)squares-greater-than-100 (s-g-t-100 '( )  ( ) 6)sum-of-squares (sos '( )  30 7)successive-concatenation (sc '(a b c d e)  (a ab abc abcd abcde)

Write! Successive-concatenation (sc '(a b c d e))  (a ab abc abcd abcde) (sc '(the big red barn))  (the thebig thebigred thebigredbarn) (define (sc sent) (accumulate (lambda ?? ) sent))

HOF: Base cases can be confusing What does (every square '()) return? –(every square "") –(every square "12345") What about (keep odd? '()) –(keep odd? "") How about (accumulate + ' ()) –(accumulate + "") –(accumulate * '()) –(accumulate word '(a)) –(accumulate + '(a) –(accumulate word '(a b)) –(accumulate + '(a b))

lambda "lambda" is a special form that lets you make a function: (lambda (param1 param2 …) statement1 statement2 ) (lambda (x) (* x x)  [a function] (every (lambda (x) (* x x) '( ))  ( )

Can a function defined by a lambda be recursive? (lambda (sent) (if (empty? sent) '() (se (square (first sent)) (???? (bf sent)))))

When do you NEED lambda? 1.When you need the context (add-suffix '-is-great '(nate sam mary))  (nate-is-great sam-is-great mary-is-great) 2.When you need to make a function on the fly

Procedures that make procedures Generally, name procedures that create procedures "make-XXX" (make-bookends 'o)  #[closure arglist=(inner-wd) d7d0e0] ((make-bookends 'o) 'hi)  ohio ((make-bookends 'to) 'ron)  toronto (define tom-bookend (make-bookends 'tom)) (tom-bookends "")  tomtom

Ha! Make a procedure that returns a procedure that takes a number X and returns a procedure that takes a number and adds X to it. –Whew!