fib 0 = 1
fib 1 = 1
fib n | n >= 2
= fib (n-1) + fib (n-2)
def fib(0), do: 1
def fib(1), do: 1
def fib(n) when n >= 2, do: fib(n-1) + fib(n-2)
match [head] + tail in [0, 1, 2, 3]:
print(head, tail)
match x with
| Some x => println$ x;
| None => println "NONE";
endmatch;
This functionality is included in switch statements.
Languages with Pattern Matching include Rust, Haskell, Elixir, Coconut, MoonBit, Felix, Egison, HOPE, Aardvark, NPL
Languages without Pattern Matching include progsbase, Veryl
View all concepts with or missing a hasPatternMatching measurement
Read more about Pattern Matching on the web: 1.