Skip to content

Instantly share code, notes, and snippets.

@okram
Last active June 8, 2020 23:12
Show Gist options
  • Save okram/1ac8f1d76204266794312288854725ab to your computer and use it in GitHub Desktop.
Save okram/1ac8f1d76204266794312288854725ab to your computer and use it in GitHub Desktop.
~/software/mmadt/vm/jvm$ bin/mmadt.sh
_____ _______
/\ | __ |__ __|
_ __ ___ _ __ ___ _____ / \ | | | | | |
| '_ ` _ \| '_ ` _ |_____/ /\ \| | | | | |
| | | | | | | | | | | / ____ \ |__| | | |
|_| |_| |_|_| |_| |_| /_/ \_\____/ |_|
mm-adt.org
//////////////////
////// nat ///////
//////////////////
// (-1,0,1) is a lst of ints
mmlang> (-1,0,1)
==>(-1,0,1)
mmlang> (-1,0,1)[a,int]
==>false
mmlang> (-1,0,1)[a,(int,int,int)]
==>true
// [-1,0,1] is a lst of ints that are merged into a single stream
mmlang> [-1,0,1]
==>-1
==>0
==>1
mmlang> [-1,0,1][a,int]
==>true{3}
// define a new datatype called nat.
// it is a refinement type constraining int to those values greater than 0.
mmlang> int[define,'nat',int[is>0]][-1,0,1][a,nat]
==>false{2}
==>true
mmlang>
//////////////////////////////
////// binary int-tree ///////
//////////////////////////////
// a collection of nested lst structures
// note the last one is (str,str) not (int,int)
mmlang> [(1,1),((1,1),(1,1)),(((1,1),(1,1)),((1,1),(1,1))),('1','1')]
==>(1,1)
==>((1,1),(1,1))
==>(((1,1),(1,1)),((1,1),(1,1)))
==>('1','1')
mmlang>
// define a tree to be (int,int) or (tree,tree) (a recursive, co-product)
// in the console '/' is a meta-character to create a new line.
mmlang> lst[define,'tree',[[is,[a,(int,int)]]|[is,[a,(tree,tree)]]]][ /
......> (1,1), /
......> ((1,1),(1,1)), /
......> (((1,1),(1,1)),((1,1),(1,1))), /
......> ('1','1')][a,tree]
==>true{3}
==>false
mmlang>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment