Review Functions. Natural Language and Dialogue Systems Lab

Similar documents
Review Web Search. Functions & Functional Abstraction & More Functions. Natural Language and Dialogue Systems Lab

Topics for section today. Homework 10 functions for loops and loading fonts

What can we do with Processing? Let s check. Natural Language and Dialogue Systems Lab Guest Image. Remember how colors work.

CISC 1600, Lab 3.1: Processing

378: Machine Organization and Assembly Language

CISC 1600, Lab 2.1: Processing

Write a program that draws this image. The ligle squares are 5x5. The screen is the default 100x100. It doesn t change.

More on Arrays CS 16: Solving Problems with Computers I Lecture #13

CSE 20. Lecture 4: Number System and Boolean Function. CSE 20: Lecture2

CISC 1600 Lecture 3.1 Introduction to Processing

CS 101 Functions. Lecture 15

Physics 2660: Fundamentals of Scientific Computing. Lecture 3 Instructor: Prof. Chris Neu

CISC 1600, Lab 2.2: Interactivity in Processing

Declarative Programming

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.

Notes from the Boards Set # 5 Page

We will start our journey into Processing with creating static images using commands available in Processing:

CS3: Introduction to Symbolic Programming. Lecture 11: Tree Recursion, beginning lists, and Midterm 2. Spring 2007 Nate Titterton

CS2630: Computer Organization Homework 1 Bits, bytes, and memory organization Due January 25, 2017, 11:59pm

CISC 1600, Lab 3.2: Interactivity in Processing

More About WHILE Loops

CS Homework 11 p. 1. CS Homework 11

Kimberly Nguyen Professor Oliehoek Introduction to Programming 8 September 2013

1 Getting started with Processing

Practice Final Examination #2

ET156 Introduction to C Programming

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.

Miscellaneous Stuff That Might Be Important.

Investigations in Number, Data, and Space for the Common Core 2012

1 Getting started with Processing

Representation of Information

Functions in Processing

(Refer Slide Time: 1:43)

CSE P 501 Exam 8/5/04

Ch. 11: References & the Copy-Constructor. - continued -

Lecture (07) Arrays. By: Dr. Ahmed ElShafee. Dr. Ahmed ElShafee, ACU : Fall 2015, Programming I

Tangent line problems

Outline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types

APCS Semester #1 Final Exam Practice Problems

CS 177 Recitation. Week 8 Methods

Solution Notes. COMP 151: Terms Test

Practice Midterm Exam #2

CS 101 Randomness. Lecture 21

PIC 10A. Review for Midterm I

Lesson 7. Reading and Writing a.k.a. Input and Output

Homework 11 Program Setup (with some IMPORTANT NEW STEPS!)

COMP Summer 2015 (A01) Jim (James) Young jimyoung.ca

CS Exam 2 Study Suggestions

CS70 - Lecture 6. Graphs: Coloring; Special Graphs. 1. Review of L5 2. Planar Five Color Theorem 3. Special Graphs:

CSE 113 A. Announcements - Lab

Variables One More (but not the last) Time with feeling

Art, Randomness, and Functions

Drawing Geometrical Objects. Graphic courtesy of Eric Roberts

CS 201 Advanced Object-Oriented Programming Lab 10 - Recursion Due: April 21/22, 11:30 PM

`Three sides of a 500 square foot rectangle are fenced. Express the fence s length f as a function of height x.

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand

CSE 351: Week 4. Tom Bergan, TA

Computer Science II Data Structures

Linked Lists CS 16: Solving Problems with Computers I Lecture #16

[ the academy_of_code] Senior Beginners

Mathematical Operations

CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28) First Name: Last Name: NetID:

What we already know. Late Days. CSE 444: Database Internals. Lecture 3 DBMS Architecture

CS 135, Fall 2010 Project 4: Code Optimization Assigned: November 30th, 2010 Due: December 12,, 2010, 12noon

Overview. Exercise 0: Implementing a Client. Setup and Preparation

CSE 115. Introduction to Computer Science I

Due Date: Two Program Demonstrations (Testing and Debugging): End of Lab

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)

Information Science 1

CSE120 Wi18 Final Review

Old 257 Exam #2s for Practice

2-D Arrays. Of course, to set each grid location to 0, we have to use a loop structure as follows (assume i and j are already defined):

Basic Input and Output

Basic Input and Output

Exploring Processing

CS 101: Computer Programming and Utilization. Abhiram Ranade

We have written lots of code so far It has all been inside of the main() method What about a big program? The main() method is going to get really

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

Repetition is the reality and the seriousness of life. Soren Kierkegaard

Machine Programming 4: Structured Data

(Refer Slide Time: 00:01:30)

BCIS 3630 Dr. GUYNES SPRING 2018 TUESDAY SECTION [JAN version] GRADER COURSE WEBSITE

Homework Assignment #3

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

Faculty: Pushpendra K Rajput Session:

Control Flow: Loop Statements

CS 221 Lecture. Tuesday, 4 October There are 10 kinds of people in this world: those who know how to count in binary, and those who don t.

CS3: Introduction to Symbolic Programming. Lecture 5:

CS101 Lecture 04: Binary Arithmetic

Functions in Processing

Structured Programming

CS Fall Homework 11 p. 1. CS Homework 11

Programming for Engineers Pointers

Class #1. introduction, functions, variables, conditionals

FLOATING POINT NUMBERS

CISC2000/ of 6

Declaring a 2D Array

CMPSCI 250: Introduction to Computation. Lecture #1: Things, Sets and Strings David Mix Barrington 22 January 2014

APCS-AB: Java. Recursion in Java December 12, week14 1

Transcription:

Review Functions Natural Language and Dialogue Systems Lab

Announcements Today: Guest Lecture on Human Computer Interaction and Design for Special Populations by Prof. Sri Kurniawan Co-Director of the Assistive Technologies Lab Functions review first Functions SUDOKU homework due Thursday Binary Arithmetic and Webpage HW assigned Thursday, due one week later

Homework 10: Layering Functions

For loops (Repetition) Repeating commands is powerful: Lightbot 2.0 used recursion, a function calling itself Symbolic Lightbot prefixed a number, 2:Step Processing uses a for loop: void setup() { size(500,200); background(0); nostroke(); smooth(); fill(255); for (int i=0; i < 16; i++) { ellipse(100+25*i, 100, 15, 15); } }

Using Functions Functions package up computation when do we use them? All the time. Write some simple code to achieve a goal 2/20/12 5

Package It Make Position Vary To put the rectangle in different places, we parameterize the position, that is, use input to the function to place the rectangle 2/20/12 6

Once Created, Use It Everywhere Now we quit thinking of drawing a rectangle, but now think of placing a 50x50 rectangle 7

Example: Clock Timer. In sample codes. Draw digital timer elements Assemble elements into digits Light digit segments to create numbers Select number based on a digit 2/20/12 8

Clocktimer.pde

Arguments Become Parameters Notice that if the DEFINITION has n parameters, the CALL needs n arguments The parameters and arguments correspond Inside of the function, the parameter, e.g. xbase, is declared and initialized to the corresponding argument, e.g. 80. Then, the definition uses it, e.g. rect(80, 40+10, 20, 40) 2/20/12 2010 Larry Snyder, CSE 10

More On Parameters Parameters: Customize each function call to a specific situation they are the input to the function Parameters are the names of the input values used inside of the procedure body Arguments are the values from outside to be used for each of the parameters 2/20/12 2010 Larry Snyder, CSE 11

Homework 10: Functions & For Loops void cell(int x, int y, int s, color tinto) void triple(int x, int y, int s, color tinto) Also functions for block( ) row( ) cellarray( )

Writing Functions Processing function definitions are typically listed after the standard blocks: setup( ), draw( ), mousepressed( ), etc. Function Call Function Definition 2/20/12 2010 Larry Snyder, CSE 13

Using Functions Once defined, functions can be called repeatedly it s the point of writing them! Function Calls Function Definition 2/20/12 2010 Larry Snyder, CSE 14

Arguments Become Parameters Notice that if the DEFINITION has n parameters, the CALL needs n arguments The parameters and arguments correspond Inside of the function, the parameter, e.g. xbase, is declared and initialized to the corresponding argument, e.g. 80. Then, the definition uses it, e.g. rect(80, 40+10, 20, 40) 2/20/12 2010 Larry Snyder, CSE 15

Parameters Parameters are automatically declared (and initialized) on a call, and remain in existence as long as the function remains unfinished When the function ends, the parameters vanish, only to be recreated on the next call It is wise to choose parameter names that help you remember exactly what they mean colorflag (Chao s code), dir (for direction) I chose xbase as the orientation point of the figure in the x direction, I use that name a lot and I know what it means 2/20/12 16

Define hexa( ) and rexa( ) just_hexa_rexa.pde Parameterize the functions by a consistent position upper left corner is good 2/20/12 17

Use hexa,rexa to make a Digit hexa_rexa_makeadigit.pde 2/20/12 2010 Larry Snyder, CSE 18

Let There Be Light (and Dark) Define the illumination of the digit hexa_rexa_makeadigit_addlight.pde Must declare two color variables, initialize to proper colors, use them in fill, and then check them 2/20/12 2010 Larry Snyder, CSE 19

Count In Lights: a function for each number Light up the digit for each number Count_in_lights.pde 2/20/12 2010 Larry Snyder, CSE 20

Select A Number To Display Given an integer, display it in lights 2/20/12 21

Create a 3 Digit Display Here s The Action 2/20/12 2010 Larry Snyder, CSE 22

Count up At The Frame Rate 2/20/12 2010 Larry Snyder, CSE 23

Functional Abstraction: Layers of Functions Review What We Did hexa three_digit sel digit one two three four five six seven eight nine zero rexa triangle, rect, triangle The computation is ONLY drawing triangles and rectangles, but we don t think of it that way to us, it s a timer 2/20/12 24

Homework 10: Functions void cell(int x, int y, int s, color tinto) void triple(int x, int y, int s, color tinto) Also functions for block( ) row( ) cellarray( )