Category talk:Nodal Concepts

From Organic Design wiki
Revision as of 02:57, 5 October 2007 by Nad (talk | contribs) (New page: == List Space == List space uses a...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

List Space

List space uses a binary trie to create an associative array in which all keys (in key:value pairs) are references to other nodes rather than strings or other datatypes. List-space content can be directly serialised or deserialised to and from semantic N3 RDF format. The core of list-space is binary traversal which in the form of a C function is as follows:

<c>
// Start at subject listItem and traverse the key as an association to a new listItem
// - key is also a listItem reference and its binary address is used as the traversal path
// - subject and key (all list-item references are ints starting at item 0)
// - if key is 0 the subject is returned unchanged, key 1 and 2 are the two single-iteration traversals
item listTraverse(item subject, item key) {
	if(key++ > 0) {
		int i,j;
		for(i = 1; i <= key >> 1; i <<= 1) {
			j = subject * 3;
			if(key & i) j++;
			if(space[j] == 0) space[j] = listInsert();
			subject = space[j];
		}
	}
	return subject;
}
</c>

Node Space

Node space extends list space by adding a set of specific concepts allowing the interpretation of list-space structure as a multi-threading schedular for task organisation and execution. The core of node-space is nodal reduction which is achieved with the following C function.

<c>
// Moves "this" to node's focus if exists then rotates loop and executes/reduces the focus item
void nodeReduce() {
    if(this = nodeLoopRotate(parent = this)) {        // Move "this" to the focus in the node's loop and rotate
        nodeSetValue(this, nodePARENT, parent);       // Update the parent association
        if(code = *nodeState(this, nodeCODE)) code(); // nodeCODE value is a pointer-index, execute as function-reference if non-zero
    }
}
</c>