Skip to content

Instantly share code, notes, and snippets.

@okram
Last active November 18, 2019 19:26
Show Gist options
  • Save okram/8b7c06cf241b6f6b1c7bd8dd4c4cfa8d to your computer and use it in GitHub Desktop.
Save okram/8b7c06cf241b6f6b1c7bd8dd4c4cfa8d to your computer and use it in GitHub Desktop.
// 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]
==>5 <= [plus,2]
// 5 is generated from [plus,2]. it can also continue with its processing by applying +3 * 2
mmadt> 5 <= [plus,2] => [plus,3][mult,2]
==>16 <= [plus,2]
// int is generated from +2 and further processed by +3 * 2
mmadt> int <= [plus,2] => [plus,3][mult,2]
==>int <= [plus,2][plus,3][mult,2]
// an old classic -- type inference with branches. note that there is no more [start].
// You simply call the function via =>.
mmadt> int => [plus,10][is,[gt,3]][branch,[mult,20][minus,7][gt,4],[plus,30]]
==>bool{?} <= [plus,10][is,bool <= [gt,3]][mult,20][minus,7][gt,4]
==>int{?} <= [plus,10][is,bool <= [gt,3]][plus,30]
mmadt> 23 => [plus,10][is,[gt,3]][branch,[mult,20][minus,7][gt,4],[plus,30]]
==>true
==>63
// you can chain instructions via => if you want (or just concatenate them via [x][y])
mmadt> int => [plus,2] => [plus,3]
==>int <= [plus,2][plus,3]
mmadt> int => [plus,2] => [plus,3] => [plus,4]
==>int <= [plus,2][plus,3][plus,4]
mmadt> int => [plus,2] => [plus,3] => [plus,4] => [gt,5]
==>bool <= [plus,2][plus,3][plus,4][gt,5]
// users can provide domain/range types if they like
*** BUG GOING ON HERE -- BUT THE IDEA IS THAT IF THEY WANT TO PROVIDE A TYPE BETWEEN ANY TWO INSTRUCTIONS, THEY CAN. ***
// rewrites uses the symbol -> which says: "don't treat the instructions as instructions,
// but as objects you can reason on. little sloopy still. need to do some thinking.
mmadt> int -> ([mult,2] <= [plus,2]) | ([mult,10] <= [plus,10])
==>int -> [choose,[is,[a,[mult,2]]] => [map,[plus,2]], [is,[a,[mult,10]]] => [map,[plus,10]]]
mmadt> (int -> ([mult,2] <= [plus,2]) | ([mult,10] <= [plus,10])) => [mult,2]
==>int <= [plus,2]
mmadt> (int -> ([mult,2] <= [plus,2]) | ([mult,10] <= [plus,10])) => [mult,2]
==>int <= [plus,2]
mmadt> (int -> ([mult,2] <= [plus,2]) | ([mult,10] <= [plus,10])) => [mult,10][plus,2]
==>int <= [plus,10][plus,2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment