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
// a query
int[plus,1][mult,[plus,2]][is,[gt,5]]
// compiling the query for a single int value
int => int[plus,1][mult,[plus,2]][is,[gt,5]]
// int{?}<=int[plus,1][mult,int[plus,2]][is,bool<=int[gt,5]]
// compiling the query for 3 int values
assertResult("[8|a->3,b->8]") {
trav(int(3))(int.to("a").plus(5).to("b"))
}
/**
This document defines a new Java object model for the mm-ADT VM.
The previous effort has Traverser functionality merged into Obj.
By separating out Traverser (the CPU) from the Obj (the RAM), there is a clean relationship between
how instructions executed on Traverser are mapped to instructions executed on Obj.
Ultimately, the Traverser's State&Model structures provide a basic internal algorithm for Traverser reasoning.
- local variable bindings
- symbol lookups
- rewrite rules
- model embeddings
int => [plus,15][is,[mult,[plus,22][mult,[id]]][gt,2]][lt,17][is,[eq,true]]
^__ traverser is an int token.
^__ you pass him into the pipeline (inst DAG)
// he creates the following inst DAG below that is now type checked/inferred.
bool{?} <= [plus,15][is,bool <= [mult,int <= [plus,15][plus,22][mult,int <= [plus,15][plus,22]]][gt,2]][lt,17][is,bool{?} <= [eq,true]]
instruction domain range
------------------------------------------------------------------------------------------------------------
// loading data into mmstor
mmlang> [str:obj{*}] <=[=mmstor][put,'users',['name':str,'age':int]{2} <= [start,['name':'marko','age':29],['name':'kuppitz','age':10]]]
==>['users':rec{2} <= [start,['name':'marko','age':29],['name':'kuppitz','age':10]]]~mmstor
// reading data from mmstor
mmlang> ['name':str,'age':int]{0,2} <=[=mmstor][get,'users'][is,[get,'name'][eq,'marko']]
==>['name':'marko','age':29]
mmlang> ['name':str,'age':int]{0,2} <=[=mmstor][get,'users'][is,[get,'name'][eq,'kuppitz']]
==>['name':'kuppitz','age':10]
mmlang> ['name':str,'age':int]{0,2} <=[=mmstor][get,'users'][is,[get,'name'][eq,'bill']]
mmlang> 'a' => (['name':'marko','age':int]{1,10} <=[map,['users':['name':'marko','age':29]]][get,'users'][is,[get,'name'][eq,'marko']])
==>['name':'marko','age':29]
mmlang> 1->2->3->4
==>[1:[2:[3:4]]]
mmlang> (1->2->3->4)<-1<-2<-3
==>4
mmlang> [int;[bool:int]]~z => (z.0) + (z.1.bool) => [explain]
instruction domain range state
---------------------------------------------------------------------------------------------------------------------------------
[map,[int;[bool:int]]~z] [int;[bool:int]]~z => [int;[bool:int]]~z -> [[int;[bool:int]]~z]
[get,0] [int;[bool:int]]~z => int -> [[int;[bool:int]]~z]
[plus,int <= [map,[int;[bool:int]]~z][get,1][get,bool]] int => int -> [[int;[bool:int]]~z]
[map,[int;[bool:int]]~z] int => [int;[bool:int]]~z -> [[int;[bool:int]]~z]
[get,1] [int;[bool:int]]~z => [bool:int] -> [[int;[bool:int]]~z]
[get,bool]
Three kids come down to the kitchen and sit around the breakfast table.
The mother asks the oldest boy what he’d like to eat.
"I’ll have some fuckin’ French toast," he says.
The mother is outraged at his language, hits him, and sends him upstairs.
She asks the middle child what he wants.
"Well, I guess that leaves more fuckin’ French toast for me," he says.
~/software/mm-adt/vm/java bin/mmadt.sh
_____ _______
/\ | __ |__ __|
_ __ ___ _ __ ___ _____ / \ | | | | | |
| '_ ` _ \| '_ ` _ |_____/ /\ \| | | | | |
| | | | | | | | | | | / ____ \ |__| | | |
|_| |_| |_|_| |_| |_| /_/ \_\____/ |_|
mm-adt.org