f(x, y) or Table

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

f(x, y) or Table

Joseph Alotta
Greetings,

I find a lot of my data needs two indices, f(x,y) instead of one, f(x).

f(x) would be implemented easily with a Dictionary,

but how do you implement f(x,y)?


I guess this is another way of asking is there a Table object or a Tuple object,

of even a graphics object Screen that has x,y coordinates with a value?


Sincerely,

Joe.






_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: f(x, y) or Table

jelena

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: f(x, y) or Table

Joseph Alotta
????



> On Apr 13, 2016, at 8:15 PM, jelena [via Smalltalk] <[hidden email]> wrote:
>
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://forum.world.st/f-x-y-or-Table-tp4889801p4889802.html
> To start a new topic under Squeak - Beginners, email [hidden email]
> To unsubscribe from Squeak - Beginners, click here.
> NAML

Reply | Threaded
Open this post in threaded view
|

Re: f(x, y) or Table

David T. Lewis
In reply to this post by Joseph Alotta
Represent your data as objects. If you are thinking of using a dictionary
to map key -> value, and you have z := f(x,y) as a function that maps x,y
to z, then make x,y be an object, and let that be the key in your dictionary
pointing to value z.

So define a class that represents x and y.

If you have a good data model, you can represent it with objects. If you
can not represent it with objects, then you probably can not represent in
in a relational database either, so revisit the data model.

Note that an index in the database sense is not the same thing as the x,y
that you are asking about. if you think in terms of tables in a database,
then x and y might be parameters in a select statement and the tables might
or might not have indices to make the query run more efficiently.

Dave


On Wed, Apr 13, 2016 at 08:46:03PM -0500, Joseph Alotta wrote:

> Greetings,
>
> I find a lot of my data needs two indices, f(x,y) instead of one, f(x).
>
> f(x) would be implemented easily with a Dictionary,
>
> but how do you implement f(x,y)?
>
>
> I guess this is another way of asking is there a Table object or a Tuple object,
>
> of even a graphics object Screen that has x,y coordinates with a value?
>
>
> Sincerely,
>
> Joe.
>
>
>
>
>
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

RE: f(x, y) or Table

Ron Teitelbaum
In reply to this post by Joseph Alotta
Hi Joseph,

| aPoint aDictionary |

aPoint := Point x: 1 y: 2.
aDictionary := Dictionary new.
aDictionary at: aPoint put: 'Success!'.
^aDictionary at: aPoint

Everything in Smalltalk is an object.  You can use a number or string as
your dictionary key but you can also use more complex objects like a Point.

The object matching is implemented in #=.  If the objects match then the
value will be returned.  

All the best,

Ron Teitelbaum

> -----Original Message-----
> From: [hidden email] [mailto:beginners-
> [hidden email]] On Behalf Of Joseph Alotta
> Sent: Wednesday, April 13, 2016 9:46 PM
> To: [hidden email]
> Subject: [Newbies] f(x, y) or Table
>
> Greetings,
>
> I find a lot of my data needs two indices, f(x,y) instead of one, f(x).
>
> f(x) would be implemented easily with a Dictionary,
>
> but how do you implement f(x,y)?
>
>
> I guess this is another way of asking is there a Table object or a Tuple
object,

>
> of even a graphics object Screen that has x,y coordinates with a value?
>
>
> Sincerely,
>
> Joe.
>
>
>
>
>
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: f(x, y) or Table

Joseph Alotta
thank you.



> On Apr 14, 2016, at 10:54 AM, Ron Teitelbaum [via Smalltalk] <[hidden email]> wrote:
>
> Hi Joseph,
>
> | aPoint aDictionary |
>
> aPoint := Point x: 1 y: 2.
> aDictionary := Dictionary new.
> aDictionary at: aPoint put: 'Success!'.
> ^aDictionary at: aPoint
>
> Everything in Smalltalk is an object.  You can use a number or string as
> your dictionary key but you can also use more complex objects like a Point.
>
> The object matching is implemented in #=.  If the objects match then the
> value will be returned.  
>
> All the best,
>
> Ron Teitelbaum
>
> > -----Original Message-----
> > From: [hidden email] [mailto:beginners-
> > [hidden email]] On Behalf Of Joseph Alotta
> > Sent: Wednesday, April 13, 2016 9:46 PM
> > To: [hidden email]
> > Subject: [Newbies] f(x, y) or Table
> >
> > Greetings,
> >
> > I find a lot of my data needs two indices, f(x,y) instead of one, f(x).
> >
> > f(x) would be implemented easily with a Dictionary,
> >
> > but how do you implement f(x,y)?
> >
> >
> > I guess this is another way of asking is there a Table object or a Tuple
> object,
>
> >
> > of even a graphics object Screen that has x,y coordinates with a value?
> >
> >
> > Sincerely,
> >
> > Joe.
> >
> >
> >
> >
> >
> >
> > _______________________________________________
> > Beginners mailing list
> > [hidden email]
> > http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://forum.world.st/f-x-y-or-Table-tp4889801p4890068.html
> To start a new topic under Squeak - Beginners, email [hidden email]
> To unsubscribe from Squeak - Beginners, click here.
> NAML

Reply | Threaded
Open this post in threaded view
|

Re: f(x, y) or Table

jelena
In reply to this post by Joseph Alotta

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners