cleaned code

This commit is contained in:
Phuntsok Drak-pa 2019-07-16 19:36:58 +02:00
parent ef5131928c
commit 0097800eba

View File

@ -1,17 +1,12 @@
(define (declare-node node-text node-generation) (define (declare-node node-text node-generation)
(string-append ;; "node" (string-append (number->string node-generation)
(number->string node-generation)
"[label=\"" "[label=\""
node-text node-text
"\"];\n")) "\"];"))
(define (make-link previous-node current-node) (define (make-link previous-node current-node)
(string-append ;; "node" (string-append (number->string previous-node) " -- "
(number->string previous-node) (number->string current-node) ";"))
" -- "
;; "node"
(number->string current-node)
";\n"))
(define (tree-to-dot-helper tree current-generation previous-generation) (define (tree-to-dot-helper tree current-generation previous-generation)
;; Helper to ~tree-to-dot~ that translates a Scheme tree with any number of ;; Helper to ~tree-to-dot~ that translates a Scheme tree with any number of
@ -42,7 +37,7 @@
;; Returns a graphvizs dot-compatible string representing a Scheme tree ;; Returns a graphvizs dot-compatible string representing a Scheme tree
(if (null? tree) "" (if (null? tree) ""
(string-append (string-append
"graph{node[shape=plaintext];graph[bgcolor=\"transparent\"];\n" "graph{node[shape=plaintext];graph[bgcolor=\"transparent\"];"
(declare-node (car tree) 0) (declare-node (car tree) 0)
(tree-to-dot-helper (cdr tree) 1 0) (tree-to-dot-helper (cdr tree) 1 0)
"}"))) "}")))