Features:
- Matching against almost any data type with a first-match policy
- Deep matching within data types and matrices
- Variable binding within matches
For alternatives to Match
, check out
- toivoh's
PatternDispatch.jl
for a more Julia-like function dispatch on patterns.
Use the Julia package manager. Within Julia, do:
Pkg.add("Match")
The package provides one macro, @match
, which can be used as:
using Match
@match item begin
pattern1 => result1
pattern2, if cond end => result2
pattern3 || pattern4 => result3
_ => default_result
end
It is possible to supply variables inside pattern, which will be bound to corresponding values.
See the documentation for examples of this and other features.