Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Marko A. Rodriguez okram

🏠
Working from home
View GitHub Profile
View stuff.java
mmlang> 5 => int+2-<(nat;nat+10)=(vertex;vertex)=>edge
==>edge:('outV'->vertex:('id'->nat:7),'inV'->vertex:('id'->nat:17))
mmlang> int => int+2-<(nat;nat+10)=(vertex;vertex)=>edge
==>edge<=int[plus,2]
[split,(nat{?}<=int[is,bool<=int[gt,0]];nat{?}<=int[is,bool<=int[gt,0]][plus,10])]
[combine,(vertex;vertex)]
[as,edge<=(vertex;vertex)
[split,('outV'->vertex<=(vertex;vertex)[get,0,_],
'inV'->vertex<=(vertex;vertex)[get,1,_])]]
View mocoerce.java
mmlang> int => vertex
==>vertex<=int[is,bool<=int[gt,0]]
[coerce,vertex{?}<=nat{?}[split,('id'->nat)]]
mmlang> int => vertex => -<(_;_)
==>(vertex:('id'->nat);vertex:('id'->nat))<=int[is,bool<=int[gt,0]]
[coerce,vertex{?}<=nat{?}[split,('id'->nat)]]
[split,(vertex:('id'->nat);vertex:('id'->nat))]
mmlang> int => vertex => -<(_;_) => edge
View branches.java
mmlang> [1,2,3] // a stream of 3 ints
==>1
==>2
==>3
mmlang> [1,2,3][id] // passing the stream through the [id] instruction (ring *)
==>1
==>2
==>3
mmlang> [1,2,3][[id],[id]] // passing the stream across two branches with [id] instructions (ring +)
==>1{2}
View objgraph2.java
// all cascading coercion is completely determined within the obj graph and thus, realized as instructions.
mmlang> :[model,digraph]
==>_
mmlang> int
==>int
mmlang> int => nat
==>nat<=int[is,bool<=int[gt,0]]
mmlang> int => nat => vertex
==>vertex<=int[is,bool<=int[gt,0]][split,('id'->nat)]
mmlang> int => nat => vertex -<(_;_)
View =>-compilation.java
int => nat[plus,1] => vertex => -<(_;_) => edge
nat <=int[is>0][plus,1]
vertex <=int[is>0][plus,1][split,('id'->nat)]
(vertex;vertex) <=int[is>0][plus,1][split,('id'->nat)][split,(vertex;vertex)]
edge <=int[is>0][plus,1][split,('id'->nat)][split,(vertex;vertex)][combine,[split,('outV'->[get,0],'inV'->[get,1])]]
View paths.java
mmlang> :[model,pg_2] // load property graph demo model #2
==>_
mmlang> 4 ~~> int // what is the path from 4 to int? simply int.
==>((int))<=4[walk,int]
mmlang> 4 ~~> str // what is the path from 4 to str? this is none. no ".toString()"
==>( )
mmlang> :[model,pg_2][define,str<=int] // lets define ".toString()"
==>_[define,str<=int]
mmlang> 4 ~~> str // what is the path from 4 to str? int then str
==>((int;str))<=4[walk,str]
View gist:d4c06a947f66198039b4e858c59d9fbf
(int;int) => (nat;nat)
..yields:
(nat;nat)<=(int;int)[combine,(nat<=int[is,bool<=int[gt,0]];nat<=int[is,bool<=int[gt,0]])]
(nat;nat)<=(int;int)[combine,(nat<=int[is,bool<=int[gt,0]];nat<=int[is,bool<=int[gt,0]])]
View traversal.java
Given [model,tp3], a graph traversal can be expressed as:
vertex[get,outE][is,[get,label][eq,'knows']][get,inV]
or w/ corresponding mmlang sugar syntax:
vertex.outE[is.label=='knows'].inV
or using auto-coercion over the following type definition:
View coerce.java
(nat;attr);(nat;attr) => edge
((nat;attr);(nat;attr)),
(vertex;vertex),
[combine,(vertex<=(nat;attr)[split,('id'->nat<=(nat;attr)[get,0,_],
'attrs'->attr<=(nat;attr)[get,1,_])];
vertex<=(nat;attr)[split,('id'->nat<=(nat;attr)[get,0,_],
'attrs'->attr<=(nat;attr)[get,1,_])])],
[split,('outV'->vertex<=(vertex;vertex)[get,0,_],
'inV'->vertex<=(vertex;vertex)[get,1,_])],
View recursive.java
mmlang> :[model,mm][define,tree<=[?0|(int;tree;int)]]
==>_[define,tree<=_[_{?}<=_[is,bool<=_[a,0]]|(int;tree;int)]]
mmlang> 0 => tree
==>tree:0
mmlang> 1 => tree
language error: 1 is not a tree
mmlang> (1;0;1) => tree
==>tree:(1;tree:0;1)
mmlang> (1;(2;0;2);1) => tree
==>tree:(1;tree:(2;tree:0;2);1)