Christian Collberg
Department of Computer Science
University of Arizona
Pattern Syntax:
fact Revisited:
| Pattern | Syntax | Example | Description |
| variable | var_name | fact n = |
n matches any argument |
| constant | literal | fact 0 = |
matches the value |
| wildcard | _ | five _ = 5 | _ matches any argument |
| (n+k) pat. | (n+k) | fact (n+1) = |
(n+k) matches any integer |
| Pattern | Syntax | Example | Description |
| cons | (x:xs) | len (x:xs) = |
matches non-empty list |
| empty | [ ] | len [ ] = 0 | matches the empty list |
| one-elem | [x] | len [x] = 1 | matches a list with exactly 1 element. |
| two-elem | [x,y] | len [x,y] = 2 | matches a list with exactly 2 elements. |
Using conditional expr:
Using patterns:
Using conditional expr:
Using patterns:
Using conditional expr:
Using patterns: