Skip to content

Instantly share code, notes, and snippets.

@Stiivi
Created January 16, 2016 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Stiivi/1e2078c0054836d2cc00 to your computer and use it in GitHub Desktop.
Save Stiivi/1e2078c0054836d2cc00 to your computer and use it in GitHub Desktop.
# Self-organizing trees
#
CONCEPT node
TAG free
SLOT left, right
CONCEPT head
TAG open, node
SLOT left, right
WHERE node, open AND NOT BOUND left ON free, node DO
BIND left TO other
IN other UNSET free
IN other SET open
WHERE node, open AND NOT BOUND right ON free, node DO
BIND right TO other
IN other UNSET free
IN other SET open
WHERE node, open AND BOUND left AND BOUND right DO
UNSET open
WORLD main
OBJECT head * 5
OBJECT node * 1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment