The change to ``classes.private`` was to simplify the code, since it was a
simplified collection routine, albeit very similar to what is in ``graphs``.
If you try out the graphs code:
CONSTANT: my-graph H{
{ 1 H{ { 1 1 } { 2 2 } } }
{ 2 H{ { 3 3 } { 6 6 } } }
{ 4 H{ { 4 4 } { 5 5 } } }
{ 5 H{ { 5 5 } { 1 1 } } }
{ 6 H{ { 6 6 } { 1 1 } } }
}
IN: scratchpad 2 [ my-graph at ] closure keys natural-sort .
{ 1 2 3 6 }
IN: scratchpad 3 [ my-graph at ] closure keys natural-sort .
{ 3 }
IN: scratchpad 4 [ my-graph at ] closure keys natural-sort .
{ 1 2 3 4 5 6 }
You can see it follows all the edges generated by the quotation (my-graph
at) from a starting vertex.
If it isn't the right abstraction for you, I'm sure it wouldn't be too hard
to write a different routine?
On Sun, Mar 24, 2013 at 12:48 AM, CW Alston <cwalsto...@gmail.com> wrote:
> Greetings folks -
>
>
> I'm experimenting with directed graph possibilites over an inverted index
> (of terms in files)
>
> that I've designed. I'm stumbling on the use of the word closure defined
> IN: graphs,
>
> using hashtables:
>
>
> USING: graphs.private kernel ;
>
> IN: graphs
>
> : closure ( obj quot -- assoc )
>
> H{ } clone [ swap (closure) ] keep ; inline
>
>
> The article on 'Directed graph utilities' suggests that:
>
>
> "You can perform queries on the graph:
>
> closure ( obj quot -- assoc )
>
>
> Directed graphs are used to maintain cross-referencing information for
> Definitions."
>
>
> I want to implement just such cross-referencing & querying with my
> inverted index graph.
>
> It seems there are no example usages of the graphs-vocab closure, but
> there is a dopplegänger
>
> definition of closure IN: classes.private, which appears to do the same
> work using hash-sets:
>
>
> USING: kernel ;
>
> IN: classes.private
>
> : closure ( obj quot -- set )
>
> HS{ } clone [ swap (closure) ] keep ; inline
>
>
> I find the only(?) example use of the classes.private closure is in the
> definition of class-usages,
>
> which is opaque to me. I can't suss out what the construction
> sets:membersthere is doing.
>
> Although the recursive (closure) in its def has an obvious analogue in
> graph's (closure), both
>
> are a mite hairy.
>
>
> Can anyone soothe my perplexity with an illustration using closure on a
> directed graph?
>
> Much obliged,
>
> ~cw
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_mar
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk