Last active
July 9, 2020 10:14
-
-
Save okram/40d3ed2e8cf06e05507d775e6520b0c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// kv-ADT | |
[define,kvstore<=kv{*},kv:('k'->obj,'v'->obj)] | |
// tp3-ADT | |
[define,graph:('V'->vertex{*},'E'->edge{*}), | |
vertex:('id'->obj,'label'->str,'properties'->property{*},'outE'->edge{*},'inE'->edge{*}), | |
edge:('id'->obj,'label'->str,'properties'->property{*},'outV'->vertex,'inV'->vertex), | |
property:([is,!['id'|'label']]->obj)] | |
// functor from kv-ADT to tp3-ADT | |
[define,graph<=kvstore-<('V'->.0[is,.k.0=='vertex'], | |
'E'->.0[is,.k.0=='edge']), | |
vertex<=kv:('k'->(is=='vertex',obj),'v'->(str->obj))<x>-< | |
('id' -> .k.1, | |
'label' -> [.v.label|.k.0], | |
'properties' -> .v, | |
'inE' -> g.E[is,.v.link.1==x.k.1], | |
'outE' -> g.E[is,.v.link.0==x.k.1]), | |
edge<=kv:('k'->(is=='edge',obj),'v'->('link'->(obj,obj),str->obj{*}))<x>-< | |
('id' -> .k.1, | |
'label' -> [.v.label|.k.0], | |
'outV' -> g.V[is,.k.1==x.v.link.0], | |
'inV' -> g.V[is,.k.1==x.v.link.1]), | |
kvstore<=-<(db),g<=_,db<=_] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment