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