Oh, thanks for the clarification. I guess I should go read the source code 
for Dict allready :)
Well, it seems a bit of a shame not beeing able to exploit the fact that 
the data is sorted, but
so far performance haven't been too bad, so I'll stick with Dict.filter for 
now.. If the time comes
I can try hack a version of Dict that supports that kind of behaviour. But 
I need to skill up first :)

I'll try searching around on github if anyone has done something similar in 
Elm-land.

fredag 10. mars 2017 10.58.06 UTC+1 skrev Martin Norbäck Olivers følgende:
>
> It would still iterate through all keys though. Filter takes a function so 
> there is no way it can lookup the key, it has to check all keys.
> You'd want a function like
> subset : comparable -> comparable -> Dict comparable a -> Dict comparable a
> which is not available at the moment.
>
> Den fredag 10 mars 2017 kl. 07:01:16 UTC+1 skrev Brian Hicks:
>>
>> Sounds like Dict.filter would work fine for this. No need to convert to a 
>> list first!
>>
>> On Mar 9, 2017, at 11:23 PM, boutros boutros boutros <
>> [email protected]> wrote:
>>
>> Hi!
>>
>> If my understanding is correct, Dict is backed by a sorted data structure 
>> (Relaxed Radix Balanced-Trees).
>> However, it does not seem expose a way obtain a subset of the data, other 
>> than to iterate through all the keys from first to last. Is this correct?
>>
>> My use case is this: I'm making an index for a graph, currently stored in 
>> a Dict, and I'm looking into ways of how to query the index efficiently. So 
>> far my only method is to iterate through all the keys and getting my 
>> selections using List.filter. However, this seems inefficient when the 
>> index is big.
>>
>> I'm new to Elm and have limited experience with functional programming, 
>> so I'm probably looking at this from a wrong angle.
>>
>> If I was working in a imperative language - I would store the index in a 
>> sorted structure, and seek in it using binary search. So for example, if my 
>> index was an alphabetically sorted list of words, and I wanted to fetch 
>> only the words starting with the letter "s" up to the letter "t", I would 
>> binary seek to first occurrence of s, obtain a cursor from there and keep 
>> reading until the first occurrence of the letter "t". 
>>
>> Is there a way to achieve something similar in Elm, perhaps using a 
>> different data structure or package?
>>
>> Regards,
>> Boutros
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to