I concur with Garth - structures like coordinates, points, etc are
non-changing in their structure and hence don't need "mapped"
references into their elements. Destructuring is the easy way to get
at the elements;
(let [[x y z] pt] ...
and they can be combined in collections, arrays, etc, and manipulated
a whole lot easier than equivalent hash maps.

My 2c.

On Sat, Feb 13, 2010 at 7:22 AM, Hozumi <fat...@googlemail.com> wrote:
> Hi,Gaarth.
> Thank you for helpful advice.
>
>
> On 2月13ζ—₯, 午後1:03, Garth Sheldon-Coulson <g...@mit.edu> wrote:
>> I have confronted a similar question in the past when deciding how to label
>> the dimensions of vectors and multidimensional arrays.
>>
>> My tentative conclusion is that it's best to use raw vectors.
>>
>> => (def v [40 41 42])
>> #'user/v
>>
>> If you need human-readable labels, build a separate index with constant
>> lookup.
>>
>> => (def vindex {:x 0 :y 1 :z 2})
>> #'user/vindex
>> => (v (:z vindex))
>> 42
>>
>> You can put v and vindex in a single hashmap or class or type or whatever.
>>
>> There are all kinds of reasons for this. The main one is that your data
>> proper remains in a pure array-like data structure and can easily be
>> processed by high-performance algorithms for things like array slicing and
>> transposition, not to mention mathematical routines. The fact that you're
>> putting human-readable names on your indices is just a convenience.
>>
>> Moreover, every time you want to get a sequence of elements out of your
>> vector, you don't want to have to loop through the hashmap pulling the
>> elements out in the right order. Mathematical vectors are orderful things
>> and should be represented in an orderful data structure. Clojure vectors are
>> ordered. Hashmaps are unordered.
>>
>> That's the conclusion I have come to, at any rate.
>>
>> Garth
>>
>>
>>
>> On Fri, Feb 12, 2010 at 10:36 PM, Hozumi <fat...@googlemail.com> wrote:
>> > Hi,all
>> > Although there is no right answer, vector seem to be preferred in many
>> > cases.
>> > Which do you prefer map or vector?
>> > Thanks!
>>
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Clojure" group.
>> > To post to this group, send email to clojure@googlegroups.com
>> > Note that posts from new members are moderated - please be patient with
>> > your first post.
>> > To unsubscribe from this group, send email to
>> > clojure+unsubscr...@googlegroups.com<clojure%2bunsubscr...@googlegroups.com
>> >  >
>> > For more options, visit this group at
>> >http://groups.google.com/group/clojure?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to