| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Some examples showing how the Binary tree module can be used |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --sized-types #-} |
| 8 |
|
| 9 |
module README.Data.Tree.Binary where |
| 10 |
|
| 11 |
open import Data.List.Base |
| 12 |
open import Data.String.Base using (String; unlines) |
| 13 |
open import Data.Tree.Binary using (Tree; leaf; node) |
| 14 |
open import Function.Base |
| 15 |
open import Agda.Builtin.Equality |
| 16 |
|
| 17 |
------------------------------------------------------------------------ |
| 18 |
-- Pretty-printing |
| 19 |
|
| 20 |
open import Data.Tree.Binary.Show using (display) |
| 21 |
|
| 22 |
_ : unlines (display |
| 23 |
$ node (node (leaf [ "plum" ]) |
| 24 |
("apricot" ∷ "prune" ∷ []) |
| 25 |
(node (leaf [ "orange" ]) |
| 26 |
("peach" ∷ []) |
| 27 |
(node (leaf [ "kiwi" ]) |
| 28 |
("apple" ∷ "pear" ∷ []) |
| 29 |
(leaf [ "pineapple" ])))) |
| 30 |
("cherry" ∷ "lemon" ∷ "banana" ∷ []) |
| 31 |
(leaf [ "yuzu" ])) |
| 32 |
≡ "cherry |
| 33 |
\ \lemon |
| 34 |
\ \banana |
| 35 |
\ \ ├ apricot |
| 36 |
\ \ │ prune |
| 37 |
\ \ │ ├ plum |
| 38 |
\ \ │ └ peach |
| 39 |
\ \ │ ├ orange |
| 40 |
\ \ │ └ apple |
| 41 |
\ \ │ pear |
| 42 |
\ \ │ ├ kiwi |
| 43 |
\ \ │ └ pineapple |
| 44 |
\ \ └ yuzu" |
| 45 |
_ = refl |