Family Day update
This commit is contained in:
parent
aac6731f2c
commit
9ad63ea473
2442 changed files with 39761 additions and 8255 deletions
16
Task/Visualize-a-tree/Common-Lisp/visualize-a-tree-3.lisp
Normal file
16
Task/Visualize-a-tree/Common-Lisp/visualize-a-tree-3.lisp
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
(use-package :iterate)
|
||||
(defun print-tree (tree value-function children-function)
|
||||
(labels
|
||||
((do-print-tree (tree prefix)
|
||||
(format t "~a~%" (funcall value-function tree))
|
||||
(iter
|
||||
(with children = (funcall children-function tree))
|
||||
(for child = (pop children))
|
||||
(while child)
|
||||
|
||||
(if children
|
||||
(progn (format t "~a├─ " prefix)
|
||||
(do-print-tree child (format nil "~a│ " prefix)))
|
||||
(progn (format t "~a└─ " prefix)
|
||||
(do-print-tree child (format nil "~a " prefix)))))))
|
||||
(do-print-tree tree "")))
|
||||
27
Task/Visualize-a-tree/Common-Lisp/visualize-a-tree-4.lisp
Normal file
27
Task/Visualize-a-tree/Common-Lisp/visualize-a-tree-4.lisp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
CL-USER>(print-tree '(a
|
||||
(aa
|
||||
(aaa
|
||||
(aaaa)
|
||||
(aaab
|
||||
(aaaba)
|
||||
(aaabb))
|
||||
(aaac)))
|
||||
(ab)
|
||||
(ac
|
||||
(aca)
|
||||
(acb)
|
||||
(acc)))
|
||||
#'car #'cdr)
|
||||
A
|
||||
├─ AA
|
||||
│ └─ AAA
|
||||
│ ├─ AAAA
|
||||
│ ├─ AAAB
|
||||
│ │ ├─ AAABA
|
||||
│ │ └─ AAABB
|
||||
│ └─ AAAC
|
||||
├─ AB
|
||||
└─ AC
|
||||
├─ ACA
|
||||
├─ ACB
|
||||
└─ ACC
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
/// a program to produce a visual representation of some tree.
|
||||
|
||||
import system'routines;
|
||||
import extensions;
|
||||
|
||||
|
|
@ -51,14 +53,14 @@ extension treeOp
|
|||
public program()
|
||||
{
|
||||
var tree := Node.new(
|
||||
new Node[]{
|
||||
Node.new("a", new Node[]
|
||||
{
|
||||
Node.new("b", new Node[]{Node.new("c")}),
|
||||
new Node[]::(
|
||||
Node.new("a", new Node[]::
|
||||
(
|
||||
Node.new("b", new Node[]::(Node.new("c"))),
|
||||
Node.new("d")
|
||||
}),
|
||||
)),
|
||||
Node.new("e")
|
||||
});
|
||||
));
|
||||
|
||||
console.writeTree(tree).readChar()
|
||||
}
|
||||
|
|
|
|||
2
Task/Visualize-a-tree/Maple/visualize-a-tree.maple
Normal file
2
Task/Visualize-a-tree/Maple/visualize-a-tree.maple
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
T := GraphTheory:-Graph([1, 2, 3, 4, 5], {{1, 2}, {2, 3}, {2, 4}, {4, 5}}):
|
||||
GraphTheory:-DrawGraph(T, style = tree);
|
||||
Loading…
Add table
Add a link
Reference in a new issue