My issue here is that I want to index on "complex" values. I was under the
impression ES6 maps solve amongst others the problem that with objects -
keys are only strings.

I want to index on 2 (or 100) properties - in this example the x and y
values. I don't want to iterate the whole collection and all the keys every
time I check for existence - that's very inefficient.

Moreover, I don't want to write a for loop over the entries every time I
check for existence - if I wanted that I'd just use an array. Also note,
we're talking about the _keys_ of the map and _not_ the values.


BTW in Python (which I reiterate is just an example) it's done via a hash
function (
https://github.com/python-git/python/blob/master/Objects/tupleobject.c#L290)
that's not the issue though.


On Mon, Feb 17, 2014 at 11:43 PM, Bradley Meck <[email protected]>wrote:

> I understand the capability of python, but that is done through
> comprehensions that do not relate to the mapping of key to value.
> In ES6 the syntax comes out to:
>
> ```
> let tuple = {x:3,y:5}
> [for (value of map.entries()) if
> (Object.keys(tuple).every((tupleKey)=>tuple[tupleKey] == value[tupleKey]))
> value]
> ```
>
> A quick comparator function for tuple like objects would be more clear
> than comprehension that does not relate to the mapping of key to value.
> Notice how the keys of `map` are never used in the comprehension.
>
>
> On Mon, Feb 17, 2014 at 3:35 PM, Benjamin (Inglor) Gruenbaum <
> [email protected]> wrote:
>
>> Hi, when you reply please reply to the list (that is, include esdiscuss
>> in the list of recipients) - otherwise I'm the only one who can read your
>> mail.
>>
>> As for your question, You might want to look into how maps (or
>> dictionaries) work in languages like Python where you can have a dictionary
>> with tuple keys for example which would let me index on `(x,y)` values.
>> This is of course a very 'simplified' example of what I'm actually doing
>> (statistical learning).
>>
>>
>> On Mon, Feb 17, 2014 at 11:31 PM, Bradley Meck <[email protected]>wrote:
>>
>>> What you are describing is a Set/Array of data that runs a filter at
>>> runtime. Could you go into some detail on why a filter on sets/arrays does
>>> not make sense for your use case? I am unsure what the original mapping of
>>> key (during .set(key, value)) to value would represent if keys are treated
>>> as many-many filters rather than 1-1 relationships for Maps in ES6.
>>>
>>
>>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to