Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

on the wasting of time

Name: Anonymous 2012-11-02 8:38

An assignment is due tomorrow for my theoretical computer science class.

I have stayed up all night to work on it.

Rather than doing productive work I am spending my time writing a program in pic to format pretty trees.

Name: Anonymous 2012-11-02 13:25

My face when it works!

The trees are still a bit lopsided, but that's just a matter of better centering the root node.


function printarrow(from, to){
    printf("Arrow from Tree%s_%d to Tree%s_%d;\n",
       treeid, from, treeid, to);
}

function printtree(tree, treeid, nlines){
#    print treeid;
#    for(i=1; i<(2^nlines); ++i){
#    printf("%d ", tree[i]);
#    }
    for(i=0; i<nlines; ++i){
    printf("move left %d * 0.4;\n", 2^(i-1));
    for(j=2^i; j<2^(i+1); ++j){
        printf("Tree%s_%d: circle radius 0.1 \"%d\";\n", treeid, j, tree[j]);
        printf("move right 0.4;\n");
        if(int(j/2) != 0){
        printf("{line from Tree%s_%d.n to Tree%s_%d.s;}\n", treeid, j, treeid, int(j/2));
        }
#        printf("%d->%d ", tree[j], tree[int(j/2)]);
    }
    printf("move down 1;\n");
    }
}

BEGIN {
   
    treeprinted = 0;
    nlines = 0;
    printf(".PS\n");
}

/^Name:/ {
    treeid=$2
}
   
/^T/ {
    ++nlines;
    for(i=2; i<=NF; ++i){
    tree[(2^(nlines-1)) + i - 2] = $i;
    }
}

/^Rel:/ {
    if(!treeprinted){
    printtree(tree, treeid, nlines);
    treeprinted = 1;
    }

    printarrow($2, $3);
}

END {
    if(!treeprinted){
    printtree(tree, treeid, nlines);
    }
    printf(".PE\n");
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List