Functions 35

Functions

I thought we'd talk

about functions

and their related

concepts next.

It's a prey

abstract, but you'

be fine as long as

you take your time

and think hard about

each new idea.

Got it.

Let's start by

defining the

co nce pt its elf.

Sounds

gd.

Functions

36 Chapter 2 The Fundamentals

Imagine the

foowing

scenario:

Captain Ichinose, in

a pleasant md,

decides to treat us

freshmen to lunch.

So we foow him

torestaurant A.

This is the

resta urant

menu.

Udon 500 yen Cuy 700 yen

Breaded pork

1000 yen

Broiled l

1500 yen

But there is

a catch,

ofcourse.

What

do you

mean?

Since he's the one paying,

he gets a say in any and

a orders.

Kind of

like this:

Foow

me!

?

Functions 37

We wouldn't reay be able to say no if he

told us to order the cheapest dish, right?

Or say, if he just told us a to order

dierent things.

Yurino

Yoshida

Yajima

Tomiyama

Udon

Cuy

Breaded pork

Broiled l

Udon for

everyone!

Yurino

Yoshida

Yajima

Tomiyama

Udon

Cuy

Breaded pork

Broiled l

Order

dierent

stu!

38 Chapter 2 The Fundamentals

Even if he told us to order our favorites,

we wouldn't reay have a choice. This might

make us the most hay, but that doesn't

change the fact that we have to obey him.

You could say that the captain's ordering

guidelines are like a “rule” that binds

elements of X to elements of Y.

Yurino

Yoshida

Yajima

Tomiyama

Udon

Cuy

Breaded pork

Broiled l

Order what

you want!

Yurino

Yoshida

Yajima

Tomiyama

Udon

Cuy

Breaded

pork

Broiled l

Rule!

?

?

?

?

X

Y

Functions 39

And that

is why...

We define a “function from

X to Y ” as the rule

that binds elements in X to elements in Y,

justlike the captain’s rules for how we

orderlunch!

This is how

wewrite it:

f is completely

arbitrary. g or h

would do just

aswe.

Gotcha.

Functions

A rule that binds elements of the set X to elements of the set Y is called “a

function from X to Y.” X is usually called the domain and Y the co-domain or

target set of the function.

function!

or

Menu

Rule

Club

member

Menu

Club

member

!

Ruleor

Start Free Trial

No credit card required