Results 1 to 12 of 12

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

  1. #1
    Newbie
    Joined
    Oct 2016
    From
    London
    Posts
    17

    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.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Newbie
    Joined
    Oct 2016
    From
    London
    Posts
    17

    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?
    Follow Math Help Forum on Facebook and Google+

  3. #3
    MHF Contributor
    Joined
    Nov 2013
    From
    California
    Posts
    5,511
    Thanks
    2328

    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.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Oct 2016
    From
    London
    Posts
    17

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

    Hi.
    Thanks for the reply.

    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
    Follow Math Help Forum on Facebook and Google+

  5. #5
    MHF Contributor
    Joined
    Nov 2013
    From
    California
    Posts
    5,511
    Thanks
    2328

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

    Quote Originally Posted by Zibbydoo View Post
    Hi.
    Thanks for the reply.

    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"
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    Oct 2016
    From
    London
    Posts
    17

    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.
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    Oct 2016
    From
    London
    Posts
    17

    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.
    Follow Math Help Forum on Facebook and Google+

  8. #8
    Newbie
    Joined
    Oct 2016
    From
    London
    Posts
    17

    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}}
    Follow Math Help Forum on Facebook and Google+

  9. #9
    Newbie
    Joined
    Oct 2016
    From
    London
    Posts
    17

    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?
    Follow Math Help Forum on Facebook and Google+

  10. #10
    Senior Member
    Joined
    Feb 2010
    Posts
    470
    Thanks
    6

    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.
    Follow Math Help Forum on Facebook and Google+

  11. #11
    Newbie
    Joined
    Jan 2017
    From
    Windsor, Ontario, Canada, Earth, Sol
    Posts
    2

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

    Is it "ages -> the power set of people"?
    Follow Math Help Forum on Facebook and Google+

  12. #12
    Senior Member
    Joined
    Feb 2010
    Posts
    470
    Thanks
    6

    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}}
    Last edited by MoeBlee; Jan 9th 2017 at 12:56 PM.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Distinct objects vs Indistinct objects
    Posted in the Statistics Forum
    Replies: 0
    Last Post: Feb 20th 2013, 09:30 AM
  2. What type of function?
    Posted in the Pre-Calculus Forum
    Replies: 1
    Last Post: Feb 16th 2013, 01:14 PM
  3. Help on a function type question
    Posted in the Pre-Calculus Forum
    Replies: 3
    Last Post: Oct 8th 2012, 10:51 PM
  4. What type of function is this?
    Posted in the Pre-Calculus Forum
    Replies: 8
    Last Post: Sep 13th 2009, 10:40 AM
  5. A special type of function...
    Posted in the Pre-Calculus Forum
    Replies: 1
    Last Post: Dec 18th 2006, 04:06 AM

/mathhelpforum @mathhelpforum