Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!newsfeed.internetmci.com!howland.reston.ans.net!ix.netcom.com!netcom.com!sehyo
From: sehyo@netcom.com (Sehyo Chang)
Subject: Re: Some help with Smalltalk
Message-ID: <sehyoDMzJsM.525@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
X-Newsreader: TIN [version 1.2 PL1]
References: <4g61v3$thi@taco.cc.ncsu.edu> <4g70iq$mf5@newsbf02.news.aol.com>
Date: Sun, 18 Feb 1996 19:07:34 GMT
Lines: 52
Sender: sehyo@netcom20.netcom.com

Ron 10111 (ron10111@aol.com) wrote:
: Regarding implementation of 10x10 array:

: First thing, unless you are doing matrices of numbers for matrix
: inversion, the first thing to do is to ask why you want a 10x10 array. 
: Nearly always in such a situation, the best representation of the problem
: isn't an array at all.  If your problem isn't "really" a 2d array, post
: another message and folks will suggest alternatives.

: That said, there are a number of approaches to creating 2d arrays.  One
: would be to use a Dictionary with keys as Point, values as Number (or
: whatever).  If one implemented the class, it might go like this:

: TwoDArray methods

: at: aPoint
:   "Answer the value at aPoint"
:   ^ dict at: aPoint

: at: aPoint put: aValue
:   "Set the value at aPoint"
:   ^ dict at: aPoint put: aValue

: at: x at: y
:   "Answer the value at x@y"
:   ^ self at: aPoint

: etc.

: Or, as you suggest, you could make an array of arrays:

: at: aPoint
:   "Answer the element at aPoint"
:   ^ ( arrays at: aPoint x ) at: aPoint y

: etc

: I must report, however, that after years of using Smalltalk, I can't
: remember a single time that I ever actually wanted a two-dimensional
: array.

: Regards,

One problem with using Dictionary is that it is much slower than array.
If you remember how dictionary work is that is does linear hashing searching
while array is no more than address arithematic.

2D array are fundamental to the any scientific and engineering application.
Also applicable to financial engineering.

-- sehyo

