Pattern matching with functions
Means of defining function behavior by cases
fun fib 0 = 0 | fib 1 = 1 | fib n = fib(n-1)+fib(n-2);
val fib = fn : int -> int
Could use conditionals, but pattern matching is often much clearer
Previous slide
Next slide
Back to first slide
View graphic version