Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: convert arrays to graphviz dot format
name
code content
( var labels = "", links = "", i = 0; var doDict = { |x, func| if(x.isKindOf(Dictionary)) { x.keysValuesDo { |key, val| func.value(val, i, key) } } { x.do(func) } }; var addNode = { |i, j, key, label = ""| labels = labels ++ "\n% [label=\"%\"]".format(i, label); links = links ++ "\n% -> %".format(j, i); if(key.notNil) { links = links ++ " [label=\"%\"; fontname=Courier]".format(key) }; }; f = { |coll| var j = i, str; doDict.(coll, { |x, k, key| i = i + 1; if(x.isCollection) { addNode.(i, j, key, ""); f.(x); } { addNode.(i, j, key, x.cs); } }); str = "\n\ndigraph {\n" ++ labels ++ "\n" ++ links ++ "\n}"; }; ) f.([1, 2, 3, [2, 3, [1, 2, 3]]];); f.([1, 2, 3, [2, (a: 3, b: [9, 2], c: { 2 + 3 }), [1, 2, 3]]];);
code description
Displays a tree from nested arrays for graphviz
use markdown for formating
category tags
comma separated, i.g. "wild, siren" (do not enter default SC class names, please)
ancestor(s)
comma separated identificators, i.g. "1-C,1-1,1-4M,1-x"
Private?
the code will be accessible by direct url and not visible in public activity
signup to submit public code without captcha
comment of change