<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I added a function fold_match/4 which can do what you require:<br>
1> Paths =
trie:new(["/usr/bin","/usr/include/X12/Xtrans","/usr/include/X11/Xtrans"]).<br>
{47,47,<br>
{{{117,117,<br>
{{{115,115,<br>
{{{114,114,{{{47,47,{{{98,105,{{...},...}},error}}},error}}},<br>
error}}},<br>
error}}},<br>
error}}}<br>
2> trie:fold_match("/usr/include/*/Xtrans", fun(K, _, L) -> [K
| L] end, [], Paths).<br>
["/usr/include/X12/Xtrans","/usr/include/X11/Xtrans"]<br>
3> <br>
<br>
On 02/06/2012 03:54 PM, Michael Truog wrote:
<blockquote cite="mid:4F306844.1060806@gmail.com" type="cite">
<meta http-equiv="Context-Type" content="text/html;
charset=ISO-8859-1">
That code doesn't currently contain regex support, but you could
iterate on the contents based on a common prefix held within the
trie, while checking each string passed to the anonymous function
to do this programmatically. To do things this way, you would
use:<br>
trie:fold_similar("/usr/include/", Function, Accumulator, Trie)<br>
<br>
Some simple pattern matching (perhaps using "*") could probably be
grafted on in a similar way, where you would be matching string
suffixes after the "*" character's last occurrence.<br>
<br>
On 02/06/2012 12:45 PM, Zabrane Mickael wrote:
<blockquote
cite="mid:E8EE9D7A-9484-4B97-ACFB-D441FB65D6B6@gmail.com"
type="cite"> Try this:
<div><a moz-do-not-send="true"
href="https://github.com/okeuday/trie">https://github.com/okeuday/trie</a></div>
<div><br>
</div>
<div>See bench:</div>
<div><a moz-do-not-send="true"
href="http://okeuday.livejournal.com/16941.html">http://okeuday.livejournal.com/16941.html</a></div>
<div><br>
</div>
<div>
<div>
<div>Regards,</div>
<div>Zabrane</div>
<div><br>
</div>
<div><br>
</div>
</div>
<div>
<div>On Feb 6, 2012, at 9:37 PM, Jon Watte wrote:</div>
<br>
<blockquote type="cite">
<div>Why does it have to be NIF? On the surface, that
looks like a data<br>
structure that might actually work reasonably well as an
Erlang native<br>
library. (Modification generates log-N garbage)<br>
<br>
Sincerely,<br>
<br>
jw<br>
<br>
<br>
--<br>
Americans might object: there is no way we would
sacrifice our living<br>
standards for the benefit of people in the rest of the
world.<br>
Nevertheless, whether we get there willingly or not, we
shall soon<br>
have lower consumption rates, because our present rates
are<br>
unsustainable.<br>
<br>
<br>
<br>
On Mon, Feb 6, 2012 at 8:43 AM, ori brost <<a
moz-do-not-send="true"
href="mailto:oribrost@gmail.com">oribrost@gmail.com</a>>
wrote:<br>
<blockquote type="cite">I'm looking for a trie NIF
library that can support strings as trie<br>
</blockquote>
<blockquote type="cite">tokens, and basic pattern
matching with a '.' like wildcard (i.e. If /<br>
</blockquote>
<blockquote type="cite">is the trie separator and the
tree contains 3 entries: /usr/bin,<br>
</blockquote>
<blockquote type="cite">/usr/include/X12/XTrans,
/usr/include/X11/Xtrans, then I can do<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">trie:get_all(["usr", "include",
'.', "XTrans"])<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">and it will return<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">[["usr","include","X11","Xtrans"],<br>
</blockquote>
<blockquote type="cite"> ["usr","include","X12","Xtrans"]]<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">It would also be nice to have a<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">trie:get_single(["usr","include",
'.', "XTrans"])<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">that returns only one of the
matching entries<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">Does anyone know of such a NIF
library? Or something similar enough<br>
</blockquote>
<blockquote type="cite">that I can modify it for these
needs?<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">Regards, OriB.<br>
</blockquote>
<blockquote type="cite">_______________________________________________<br>
</blockquote>
<blockquote type="cite">erlang-questions mailing list<br>
</blockquote>
<blockquote type="cite"><a moz-do-not-send="true"
href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
</blockquote>
<blockquote type="cite"><a moz-do-not-send="true"
href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote>
_______________________________________________<br>
erlang-questions mailing list<br>
<a moz-do-not-send="true"
href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a moz-do-not-send="true"
href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div>
</blockquote>
</div>
<br>
<div>
<div><br>
</div>
</div>
</div>
<pre>
_______________________________________________
erlang-questions mailing list
<a moz-do-not-send="true" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a moz-do-not-send="true" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>