Description Usage Arguments Details Examples
This function is used when you want to test for more than one pattern in parallel.
1 |
... |
The patterns/expressions to combine |
If you want to test two or more patterns against the same number of values,
then you can use this function to combine the values and expressions
in a cases()
(or related) function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | llist := NIL | CONS(car, cdr : llist)
compare_llists <- function(l1, l2) {
cases(..(l1, l2),
..(NIL, NIL) -> TRUE,
..(NIL, .) -> FALSE,
..(., NIL) -> FALSE,
..(CONS(car1,cdr1), CONS(car2,cdr2)) ->
car1 == car2 && compare_llists(cdr1, cdr2)
)
}
compare_llists(NIL, NIL)
compare_llists(CONS(1, NIL), CONS(1, NIL))
compare_llists(CONS(1, NIL), NIL)
compare_llists(CONS(1, NIL), CONS(2, NIL))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.