Start reuse similar layouts

This commit is contained in:
J.Teeuwissen 2023-05-06 15:14:11 +02:00 committed by Folkert
parent b32cd5687b
commit d82f3ee09d
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
6 changed files with 324 additions and 79 deletions

View file

@ -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
"#
)
}