# 10. Function I

60 %
40 %
Education

Published on February 24, 2014

Author: JosephHenryMurphy

Source: slideshare.net

From last time… • Global vs. local variable scope! • Making static assets with saveFrame()

Functions I CAP

Functions Review void setup() {} void draw() {} • We can do two things with functions:! ! 1. call a function:! ! ! size(500,500); 2. deﬁne a function:! ! ! void size(int width, int height) {}

Deﬁning a Function the type of value we expect to be ‘returned’ the arguments we can pass in returnType functionName( argumentList ) { // some code goes here }

the variable type we expect to be ‘returned’ the arguments we will pass in returnType functionName( argumentList ) { // some code goes here } 1. Function Name: a name! 2. Input: the variable types of arguments we will pass in! 3. Output: the variable type that will be returned ( void signiﬁes that we do not expect returned value )

Demo! square() function

Why functions? • Functions organize code in a way that humans can understand! • Modularity: smaller, more readable, more manageable bits of code; it’s debuggable!! • Reusability: you can reuse code within a sketch (two pong paddles) or between sketches

Example Organized into functions vs. pure chaos

Time Permitting! Demo! Make Pong Functions

For next time… • Read Shiffman, p. 107–119 (Functions II)! • Continue (or start) working on Iteration 1 Quiz 2! Variables, Conditionals, & Loops

 User name: Comment:

January 21, 2019

January 21, 2019

January 6, 2019

January 21, 2019

January 21, 2019

January 21, 2019

## Related pages

### Function (mathematics) - Wikipedia, the free encyclopedia

In mathematics, a function is a relation between a set of inputs and a set of permissible outputs with the property that each input is related to exactly ...

### Functions - C++ Tutorials - cplusplus.com - The C++ ...

Functions Functions allow to structure programs in segments of code to perform individual tasks. In C++, a function is a group of statements that is given ...

### DLMF: 10.2 Definitions

Bessel Functions of the Third Kind (Hankel Functions) Keywords: Hankel functions. These solutions of (10.2.1) are denoted by H ν (1) ⁡ (z) and H ν (2 ...

### What is a Function? - Math is Fun - Maths Resources

" is the classic way of writing a function. And there are other ways, as you will see! Input, Relationship, Output. ... (10) = 10 × 20 = 200 cm.

### Functions 10 Inverse of a Function - YouTube

Defines the inverse of a function, an inverse function, and shows how to find the inverse of 1-1 functions. Youtube videos by Julie Harland are ...

### Chapter 10 Bessel Functions - DLMF:

10.66 Expansions in Series of Bessel Functions; 10.67 Asymptotic Expansions for Large Argument; 10.68 Modulus and Phase Functions;

### PHP 5 Functions - W3Schools Online Web Tutorials

PHP User Defined Functions. Besides the built-in PHP functions, we can create our own functions. A function is a block of statements that can be used ...