10. Function I

60 %
40 %
Information about 10. Function I
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. define a function:! ! ! void size(int width, int height) {}

Defining 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 signifies 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

Add a comment

Related presentations

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 ...
Read more

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 ...
Read more

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 ...
Read more

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.
Read more

PHP: Math Functions - Manual - PHP: Hypertext Preprocessor

Read more

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 ...
Read more

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;
Read more

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 ...
Read more

Functions · Advanced R. - Had

Functions. Functions are a fundamental building block of R: to master many of the more advanced techniques in this book, you need a solid foundation in how ...
Read more

R Library: Introduction to functions - Institute for ...

R Library: Introduction to functions. The R program (as a text file) for the code on this page. In order to see more than just the results from the ...
Read more