Skip to content

Instantly share code, notes, and snippets.

View okram's full-sized avatar
🏠
Working from home

Marko A. Rodriguez okram

🏠
Working from home
View GitHub Profile
person[name:str~a,age:int~b]{*}~c =>[id]
| <=[=mongo][get,users]
| [is,[get,name][eq,a]]
| [map,[name:[get,'first'][plus,[get,'last']],
| age:2019-[get,'dob']]]
|
|-[-rule]([dedup]|[order]) => [id] | [count] => 100
|-[-path][put,'c',c]
|-[-loop][is,[get,i][a,repeat]][incr]
|-[-akka][is,[get,remote]][put,c,akka[ip:127.0.0.1,port:2222]]
@okram
okram / inst.groovy
Last active November 18, 2019 19:26
// int is the input to [plus,2]. when executed, it is the output of [plus,2]
mmadt> int => [plus,2]
==>int <= [plus,2]
// => is like function call
mmadt> 5 => [plus,2]
==>7
// if there is no input to the instruction, then nothing happens.
mmadt> 5 <= [plus,2]
mmadt> [start,int][plus,10][is,[gt,3]][branch,[mult,20][minus,7][gt,4],[plus,30]]
==>bool{?} <= [is,[a,int]][plus,10][is,bool <= [is,[a,int]][gt,3]][mult,20][minus,7][gt,4]
==>int{?} <= [is,[a,int]][plus,10][is,bool <= [is,[a,int]][gt,3]][plus,30]
mmadt> [start,int][plus,10][is,[gt,3]] * ([mult,20][minus,7][gt,4] + [plus,30])
==>bool{?} <= [is,[a,int]][plus,10][is,bool <= [is,[a,int]][gt,3]][mult,20][minus,7][gt,4]
==>int{?} <= [is,[a,int]][plus,10][is,bool <= [is,[a,int]][gt,3]][plus,30]
// type checking/inference
// The result is the compiled bytecode which shows the types for nested sequences
mmadt> obj{0} <= [start,int][plus,5][mult,5][is,[gt,5]][plus,100][is,[mult,45][minus,10][gt,0]]
==>int{?} <= [start,int][plus,5][mult,5][is,bool <= [gt,5]][plus,100][is,bool{?} <= [mult,45][minus,10][gt,0]]
// instance execution
// take the resultant instruction above and plug in 10 for int at the [start]
mmadt> int{?} <= [start,10][plus,5][mult,5][is,bool <= [gt,5]][plus,100][is,bool{?} <= [mult,45][minus,10][gt,0]]
// Types in Tensors
// Types as "inclusion-predicates" or subspaces in {}-quantifier tensors // SIDENOTE: We need to be more strict on the quantifier ring -- ordered,ring,unity. max and min make life easier).
// mm-ADT instruction (mmlang 'assembly')
int{0,5} <= [start,int{5}][plus,5][mult,5][is,bool{5} <= [start,bool{5}][gt,5]][plus,100][is,bool{0,5} <= [start,int{0,5}][mult,45][minus,10][gt,0]]
// the above in "block form"-syntax
if(((int{5} + 5) * 5) > 5) {
bool{5} + 100
@okram
okram / inst.groovy
Last active November 13, 2019 05:25
_____ _______
/\ | __ |__ __|
_ __ ___ _ __ ___ _____ / \ | | | | | |
| '_ ` _ \| '_ ` _ |_____/ /\ \| | | | | |
| | | | | | | | | | | / ____ \ |__| | | |
|_| |_| |_|_| |_| |_| /_/ \_\____/ |_|
mm-adt.org
mmadt> int{5} // 5 int tokens
EXPLAIN: int <= [start,3,5,6][plus,2][map,[plus,4][plus,[mult,1]][count]][count][sum][count]
[start,3,5,6]: int -> int{3}
[plus,2]: int{3} -> int{3}
[map,[plus,4][plus,[mult,1]][count]]: int{3} -> 1{3}
[plus,4]: int -> int
[plus,[mult,1]]: int -> int
[mult,1]: int -> int
[count]: int -> 1
[count]: 1{3} -> 3
[sum]: 3 -> 3
Computing via Model Coupling
----------------------------
/**
The obj in mm-ADT and the traverser in TP3 wrap some primitive data type and
decorate the primitive with extra computaitonal metadata. These decorations
transform what would be a regular expression into a more expressive structure (memory).
Here are the current "decorations" over obj in mm-ADT.
**/
mmadt> int <= [start,int{4}][div,2][mult,7]
error: int does not support divison
mmadt>
_____ _______
/\ | __ |__ __|
_ __ ___ _ __ ___ _____ / \ | | | | | |
| '_ ` _ \| '_ ` _ |_____/ /\ \| | | | | |
| | | | | | | | | | | / ____ \ |__| | | |
|_| |_| |_|_| |_| |_| /_/ \_\____/ |_|
mm-adt.org
mmadt> obj{0} <= [explain,int <= [start,1,2,3][plus,2][map,45][mult,2][sum][count][count]]