Description Usage Arguments Details Value See Also Examples
Creates a function that can contain expressions of a type defined by the
:= operator. The first argument of the generated function
will be matched against patterns provided in the
... parameter of
A list of variables for the function in addition
the data to be matched against which will automatically added
When you call the generated function, and the first argument is matching a pattern, it evaluates the expression the pattern is associated with. During matching, any symbol that is not quasi-quoted will be considered a variable, and matching values will be bound to such variables and be available when an expression is evaluated.
Functions created with
case_func do not support the
but you can always create constructors for fixed-number tuples, e.g.
tuples := ..(first, second) | ...(first, second, third)
Be careful not to use
. here, if you use dot as a generic
A function that can pattern match
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
linked_list := NIL | CONS(car, cdr : linked_list) lst <- CONS(1, CONS(2, CONS(3, NIL))) len <- case_func(acc = 0, NIL -> acc, CONS(car,cdr) -> len(cdr, acc + 1) ) len(lst) list_sum <- case_func(acc = 0, NIL -> acc, CONS(car,cdr) -> list_sum(cdr, acc + car) ) list_sum(lst) tuples := ..(first, second) | ...(first, second, third) f <- case_func(..(.,.) -> 2, ...(.,.,.) -> 3) f(..(1, 2)) f(...(1, 2, 3))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.