1
1
mirror of https://github.com/urbit/shrub.git synced 2024-12-25 21:12:56 +03:00

graph-store: use +lien instead of manual recursion

This commit is contained in:
Logan Allen 2021-04-14 15:39:34 -05:00
parent b319928059
commit 45fb7e69f3

View File

@ -215,27 +215,27 @@
++ check-for-duplicates
|= [=graph:store nodes=(set index:store)]
^- ?
=/ node-list ~(tap in nodes)
|-
?~ node-list %.n
?: (has-node graph i.node-list) %.y
$(node-list t.node-list)
::
++ has-node
|= [=graph:store =index:store]
^- ?
=/ node=(unit node:store) ~
|-
?~ index
?=(^ node)
?~ t.index
?=(^ (get:orm graph i.index))
=. node (get:orm graph i.index)
?~ node %.n
?- -.children.u.node
%empty %.n
%graph $(graph p.children.u.node, index t.index)
==
|^
%+ lien ~(tap in nodes)
|= =index:store
(has-node graph index)
::
++ has-node
|= [=graph:store =index:store]
^- ?
=/ node=(unit node:store) ~
|-
?~ index
?=(^ node)
?~ t.index
?=(^ (get:orm graph i.index))
=. node (get:orm graph i.index)
?~ node %.n
?- -.children.u.node
%empty %.n
%graph $(graph p.children.u.node, index t.index)
==
--
::
++ sort-nodes
|= nodes=(map index:store node:store)