CS10 The Beauty and Joy of Computing Lecture #4 : Functions 2011-09-12 UC Berkeley EECS Lecturer SOE Dan Garcia Researchers at Microsoft and UW are working.

Slides:



Advertisements
Similar presentations
Silicon Valley CSTA Presents: The Beauty and Joy of Computing Josh Paley, Teacher Computer Science & Mathematics Henry M. Gunn HS (Palo Alto, CA)
Advertisements

CS10 The Beauty and Joy of Computing Lecture #7 Algorithmic Complexity One million Wi-Fi devices isn’t cool. You know what’s cool? A Billion.
The Beauty and Joy of Computing Lecture #18 Besides Blocks I: Intro to Python Amazon Dash is Not an April Fools Joke UC Berkeley EECS Head TA Michael Ball.
CS10 The Beauty and Joy of Computing Lecture #10 Social Implications of Computing Having just returned from the UC Online Pilot Project Workshop,
CS10 The Beauty and Joy of Computing Lecture #11 : Recursion II Microsoft filed a patent that proposed to use the 3D depth camera to estimate.
4/25/08Prof. Hilfinger CS164 Lecture 371 Global Optimization Lecture 37 (From notes by R. Bodik & G. Necula)
CS10 The Beauty and Joy of Computing Lecture #1 Welcome; Abstraction At CES 2011 in Vegas, companies showed lots of tablets and internet TV.
CS39N The Beauty and Joy of Computing Lecture #11 Recursion II Researchers at Microsoft, UW and U Toronto have come up with a technique to interact.
CS10 The Beauty and Joy of Computing Lecture #5 : Programming Paradigms Intel has shown demos of the game Wolfenstein whose visual images weren’t.
CS10 The Beauty and Joy of Computing Lecture #1 Welcome; Abstraction Watch the student testimonials about CS10, what it means to them, and how.
CS10 The Beauty and Joy of Computing Lecture #17 Higher Order Functions I Silicon (normally what processors are made of) is rigid and expensive,
CS10 The Beauty and Joy of Computing Lecture #5 : Programming Paradigms Times like these make us all appreciate the value of freedom… China.
CS10 The Beauty and Joy of Computing Lecture #25 : Tree Recursion The newly released (and much- hyped) Microsoft Kinect system for the XBOX.
Prof. Fateman CS 164 Lecture 221 Global Optimization Lecture 22.
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.
Chapter 2 Writing Simple Programs
CS39N The Beauty and Joy of Computing Lecture #11 Recursion III It has been a challenge to power electronic components implanted within a body.
CS39N The Beauty and Joy of Computing Lecture #6 : Programming Paradigms In response to a 30,000+ signature petition, British PM Gordon Brown.
The Beauty and Joy of Computing Curriculum and the AP CS: Principles project Brian Harvey, UC Berkeley Dan Garcia, UC Berkeley Jens Mönig, MioSoft.
CS10 : The Beauty and Joy of Computing Lecture #10 Social Implications of Computing CS10 has been chosen as one of 30 courses (all across 10.
The Beauty and Joy of Computing Lecture #6 Algorithms Alan Turing ( ) would have turned 100 this year. He was a brilliant British mathematician.
RELATION … any set of points RELATION … any set of points { (3,6), (-4,5), (0,2) }
Grammars and Parsing. Sentence  Noun Verb Noun Noun  boys Noun  girls Noun  dogs Verb  like Verb  see Grammars Grammar: set of rules for generating.
CS61A Lecture 2 Functions and Applicative Model of Computation Tom Magrino and Jon Kotker UC Berkeley EECS June 19, 2012.
CSC 1701B Computing: Science and Creativity. Outline  Types  Variables  Operators  Control: sequence, selection, repetition  Functions (block headings.
Functional Programing Referencing material from Programming Language Pragmatics – Third Edition – by Michael L. Scott Andy Balaam (Youtube.com/user/ajbalaam)
The Beauty and Joy of Computing Lecture #1 Welcome; Abstraction Watch the student testimonials about the course, what it means to them, and how it has.
The Beauty and Joy of Computing Lecture #5 Programming Paradigms Story details the move to Digital of many things precious to us – music, photos, videos.
Prof. Aiken CS 169 Lecture 61 Project Planning CS169 Lecture 6.
Fall Week 3 CSCI-141 Scott C. Johnson.  Say we want to draw the following figure ◦ How would we go about doing this?
UC Berkeley EECS Sr Lecturer SOE Dan Garcia printing-aims-to-prevent-a-piracy-plague/ Quest.
Computer Science Department Data Structure & Algorithms Lecture 8 Recursion.
The role of data mining in the last presidential election. A mind-blowing piece on how the Obama campaign used various sources of data to target voters.
Games Development 2 Concurrent Programming CO3301 Week 9.
CS10 The Beauty and Joy of Computing Lecture #1 Welcome; Abstraction The algorithm is rapidly taking over vital functions of businesses, from.
The Beauty and Joy of Computing Lecture #5 Programming Paradigms UC Berkeley EECS Sr Lecturer SOE Dan Garcia invent.citris-uc.org motherboard.vice.com/read/click-print-gun-the-inside-story-of-the-3d-printed-gun-movement-video.
Current Assignments Homework 2 is available and is due in three days (June 19th). Project 1 due in 6 days (June 23 rd ) Write a binomial root solver using.
The Beauty and Joy of Computing Lecture #6 Algorithms MIT researchers recently created an algorithm which they say will be able to predict what topics.
The Beauty and Joy of Computing Lecture #10 Social Implications of Computing Online education now has a player in the open access / free education space,
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Math – What is a Function? 1. 2 input output function.
The Beauty and Joy of Computing Lecture #6 Algorithms I UC Berkeley EECS Sr Lecturer SOE Dan Garcia.
1/32 This Lecture Substitution model An example using the substitution model Designing recursive procedures Designing iterative procedures Proving that.
The Beauty and Joy of Computing Lecture #5 Programming Paradigms invent.citris-uc.org
The Beauty and Joy of Computing Lecture #17 Social Implications of Computing III Instructor: Sean Morris Online education now has a player in the open.
Fall 2008Programming Development Techniques 1 Topic 17 Assignment, Local State, and the Environment Model of Evaluation Section 3.1 & 3.2.
The Beauty and Joy of Computing Lecture #7 Algorithms II minors-delete-activity/story?id= /
The Beauty and Joy of Computing Lecture #12 Social Implications of Computing I Online education now has a player in the open access / free education space,
The Beauty and Joy of Computing Lecture #7 Algorithmic Complexity “Data scientists at Yahoo are using prediction markets – along with polls, sentiment.
UC Berkeley EECS Sr Lecturer SOE Dan Garcia printing-aims-to-prevent-a-piracy-plague/ Quest.
CS 104 – Fall 2011 Exploring Computer Science Build Your Own Blocks September 19, 2011.
CS61A Lecture 1 Introduction and Basics Tom Magrino and Jon Kotker UC Berkeley EECS June 18, 2012.
The Beauty and Joy of Computing Lecture #1 Welcome; Abstraction Watch the student testimonials about the course, what it means to them, and how it has.
UC Berkeley EECS Lecturer SOE Dan Garcia The success of Apple’s Siri (only available on the iPhone 4S) has sparked competition, to be sure. Google’s IRIS.
CS10 : The Beauty and Joy of Computing Lecture #5 Programming Paradigms If you visited google.com on Saturday, you saw a tribute to this founding.
UC Berkeley EECS Sr Lecturer SOE Dan Garcia Valve (video game makers of Half-Life) believes the future of video games may not be in the input device (ala.
The Beauty and Joy of Computing Lecture #6 Algorithms I Jon Kotker UC Berkeley EECS 2010, 2013 Microsoft
Functional Programming
CS314 – Section 5 Recitation 9
Chapter 2 Writing Simple Programs
Yahoo predicts contest already!
UC Berkeley EECS Sr Lecturer SOE Dan Garcia
The Beauty and Joy of Computing Lecture #4 Functions
CSC 221: Computer Programming I Fall 2005
Unit I Flash Cards Start.
This Lecture Substitution model
Javascript Chapter 19 and 20 5/3/2019.
Materials Reminders.
Coming up Variables Quick look at scope Primitives Objects
Lecture 6 - Recursion.
Presentation transcript:

CS10 The Beauty and Joy of Computing Lecture #4 : Functions UC Berkeley EECS Lecturer SOE Dan Garcia Researchers at Microsoft and UW are working on a system that uses the fact that your body can act as an antenna and notes how ambient electric fields change to figure out what your position or motion was. The idea is you don’t need a camera or Wiimote to interact with it! gestures-to-control-electronic-devices.html Quest (first exam) in this room in 7 days!!

UC Berkeley CS10 “The Beauty and Joy of Computing” : Functions (2) Garcia, Fall 2011 Enrollment – everyone IS in

UC Berkeley CS10 “The Beauty and Joy of Computing” : Functions (3) Garcia, Fall 2011  You are going to learn to write functions, like in math class: y = sin(x)  sin is the function  x is the input  It returns a single value, a number Generalization (in CS10) REVIEW “Function machine” from Simply Scheme (Harvey) x sin

UC Berkeley CS10 “The Beauty and Joy of Computing” : Functions (4) Garcia, Fall 2011 Function basics  Functions take in 0 or more inputs and return exactly 1 output  The same inputs MUST yield same outputs.  Output function of input only  Other rules of functions  No state (prior history)  No mutation (no variables get modified)  No side effects (nothing else happens)

UC Berkeley CS10 “The Beauty and Joy of Computing” : Functions (5) Garcia, Fall 2011 Which is NOT a function? a) b) c) d) e)

UC Berkeley CS10 “The Beauty and Joy of Computing” : Functions (6) Garcia, Fall 2011  Domain  The “class” of input a function accepts  Examples  Range  All the possible return values of a function  Examples More Terminology (from Math)

UC Berkeley CS10 “The Beauty and Joy of Computing” : Functions (7) Garcia, Fall 2011  If a function only depends on the information it gets as input, then nothing else can affect the output.  It can run on any computer and get the same answer.  This makes it incredibly easy to parallelize functions.  Functional programming is a great model for writing software that runs on multiple systems at the same time. Why functions are great! Datacenter

UC Berkeley CS10 “The Beauty and Joy of Computing” : Functions (8) Garcia, Fall 2011  Scratch  MIT  Maintained by MIT  Huge community  Sharing via Website  No functions   Scratch 2.0 in Flash  No iOS devices.   scratch.mit.edu  BYOB (to be “S NAP !”)  Based on Scratch code  Maintained by jens & Cal  Growing community  No sharing (yet)   Functions! … “Blocks”  BYOB 4.0 in HTML5  All devices  byob.berkeley.edu Scratch  BYOB (Build Your Own Blocks)

UC Berkeley CS10 “The Beauty and Joy of Computing” : Functions (9) Garcia, Fall 2011 Why use functions? 1 The power of generalization!

UC Berkeley CS10 “The Beauty and Joy of Computing” : Functions (10) Garcia, Fall 2011 Why use functions? 2 They can be composed together to make even more magnificent things. They are literally the building blocks of almost everything that we create when we program. We call the process of breaking big problems down into smaller tasks functional decomposition

UC Berkeley CS10 “The Beauty and Joy of Computing” : Functions (11) Garcia, Fall 2011  Command  No outputs, meant for side-effects  Reporter (Function)  Any type of output  Predicate (Function)  Boolean output  (true or false) Types of Blocks

UC Berkeley CS10 “The Beauty and Joy of Computing” : Functions (12) Garcia, Fall 2011 Quick Preview: Recursion Recursion is a technique for defining functions that use themselves to complete their own definition. We will spend a lot of time on this. M. C. Escher : Drawing Hands

UC Berkeley CS10 “The Beauty and Joy of Computing” : Functions (13) Garcia, Fall 2011  Computation is the evaluation of functions  Plugging pipes together  Each pipe, or function, has exactly 1 output  Functions can be input!  Features  No state  E.g., variable assignments  No mutation  E.g., changing variable values  No side effects  Need BYOB not Scratch Functional Programming Summary en.wikipedia.org/wiki/Functional_programming f(x)=(2+3)* x * x f x