mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
allow lowlevel and match
This commit is contained in:
parent
9b58c0fb9c
commit
d7304f86e5
4 changed files with 326 additions and 9 deletions
|
@ -3013,3 +3013,40 @@ fn rb_tree_fbip() {
|
|||
"#
|
||||
)
|
||||
}
|
||||
|
||||
#[mono_test]
|
||||
fn specialize_after_match() {
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
main =
|
||||
listA : LinkedList Str
|
||||
listA = Nil
|
||||
|
||||
listB : LinkedList Str
|
||||
listB = Nil
|
||||
|
||||
longestLinkedList listA listB
|
||||
|
||||
LinkedList a : [Cons a (LinkedList a), Nil]
|
||||
|
||||
longestLinkedList : LinkedList a, LinkedList a -> Nat
|
||||
longestLinkedList = \listA, listB -> when listA is
|
||||
Nil -> linkedListLength listB
|
||||
Cons a aa -> when listB is
|
||||
Nil -> linkedListLength listA
|
||||
Cons b bb ->
|
||||
lengthA = (linkedListLength aa) + 1
|
||||
lengthB = linkedListLength listB
|
||||
if lengthA > lengthB
|
||||
then lengthA
|
||||
else lengthB
|
||||
|
||||
linkedListLength : LinkedList a -> Nat
|
||||
linkedListLength = \list -> when list is
|
||||
Nil -> 0
|
||||
Cons _ rest -> 1 + linkedListLength rest
|
||||
"#
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue