mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-18 19:10:18 +00:00
Start reuse similar layouts
This commit is contained in:
parent
b32cd5687b
commit
d82f3ee09d
6 changed files with 324 additions and 79 deletions
|
@ -2923,3 +2923,35 @@ fn error_on_erroneous_condition() {
|
|||
"#
|
||||
)
|
||||
}
|
||||
|
||||
#[mono_test]
|
||||
fn binary_tree_fbip() {
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
main =
|
||||
tree = Node (Node (Node (Node Tip Tip) Tip) (Node Tip Tip)) (Node Tip Tip)
|
||||
checkFbip tree
|
||||
|
||||
Tree : [Node Tree Tree, Tip]
|
||||
|
||||
check : Tree -> Num a
|
||||
check = \t -> when t is
|
||||
Node l r -> check l + check r + 1
|
||||
Tip -> 0
|
||||
|
||||
Visit : [NodeR Tree Visit, Done]
|
||||
|
||||
checkFbip : Tree -> Num a
|
||||
checkFbip = \t -> checkFbipHelper t Done 0
|
||||
|
||||
checkFbipHelper : Tree, Visit, Num a-> Num a
|
||||
checkFbipHelper = \t, v, a -> when t is
|
||||
Node l r -> checkFbipHelper l (NodeR r v) (a + 1)
|
||||
Tip -> when v is
|
||||
NodeR r v2 -> checkFbipHelper r v2 a
|
||||
Done -> a
|
||||
"#
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue