Thread: Type of a function that maps to a set of objects

1. Type of a function that maps to a set of objects

I have a function that maps to a set of objects and I am totally confused by how to work out the type of the function.

So as an example a function that gets people of a certain age. A set of people such as {Mike, Claire, Paul, Christine}, and a function people(x) would return everyone of age x. So getPeople(25) would map to {Mike, Claire}

How do I work out the type? I thought it was getPeople : ages -> people but I've been told it shouldn't be people as it's not returning a person but a set of people.

Any help with this would be great thanks.

2. Re: Type of a function that maps to a set of objects

Ah, would it map to a subset of people? How would you write that out? getPeople : ages -> er, a subset of people. How do I write that bit?

3. Re: Type of a function that maps to a set of objects

It sounds as if your function returns a list of people.

Do you have an object created of type PeopleList?

If not it sounds like you should create one.

you could then create a member function

PeopleList PeopleList.isAge(uint age)

which would return a PeopleList object which is a, possibly null, subset of the people listed in the calling object that are of the passed age.

There may be a more standard way of doing this via references or something, my oop is very rusty and out of date, but this is the general idea.

4. Re: Type of a function that maps to a set of objects

Hi.

That does seem like a good idea but this is part of my coursework for my discrete maths lectures. I have to create a set of people and use that function to get a set of people of a certain age and specify the type of the function. Getting there but confused by that last bit.

Maybe ages -> someotherset subset/equal people

5. Re: Type of a function that maps to a set of objects

Originally Posted by Zibbydoo
Hi.

That does seem like a good idea but this is part of my coursework for my discrete maths lectures. I have to create a set of people and use that function to get a set of people of a certain age and specify the type of the function. Getting there but confused by that last bit.

Maybe ages -> someotherset subset/equal people
my recommendation at this point is talk to the prof and see how they interpret the problem.

There is no atomic type that is a "group of person objects"

6. Re: Type of a function that maps to a set of objects

Thanks.
I asked about it today and was told that it's not ages -> people but ages -> something else and I have to think about what that is as the function is mapping to a subset of people, not directly to people.

7. Re: Type of a function that maps to a set of objects

From what I've just read I think the function getPeople is a multivalued function.

8. Re: Type of a function that maps to a set of objects

Thinking more f : A -> B defines the function from domain A to codomain B. So could I just define the codomain as {{Mike, Claire}, {Christine}, {Paul}}

9. Re: Type of a function that maps to a set of objects

He's happy with the codomain of the function being what I did up there. Also got to use set notation to get the age of a person using the function. Is this valid set notation?

{y | y ∈ Ages ^ x ∈ People => x ∈ getPeople(y)}

Can an implication go in set notation?

10. Re: Type of a function that maps to a set of objects

Is this a particular programming language or something like that? Otherwise in plain old set theory:

The domain of f is the set of natural numbers and each value of the function is a set of people.

f = {<x y> | x is a natural number and y = {p | p is a person whose age is x}}

That's all there is to it.

11. Re: Type of a function that maps to a set of objects

Is it "ages -> the power set of people"?

12. Re: Type of a function that maps to a set of objects

Yes.

Let G = the set of ages
Let S = the set of people
Let PS = the power set of S

f: G -> PS

which translates to English as

"f is a function from G into PS."

or

"f is a function. The domain of f is G. The range of f is a subset of PS."

/

In particular

f = <x y> | x in G & y = {z | z in S & the age of z is x}}