19 days ago
Scala has some of the most advanced pattern matching machinery. This package is an attempt to mimic those capabilities in Julia. Features include:
For alternatives to
Match, check out the following modules
PatternDispatch.jl for a more Julia-like function dispatch on patterns.
Match.jl which is a similar, but (at this writing) less complete module for pattern matching.
Note that Zach's
Match.jl is also not listed as an available package for Julia. (Zach kindly offered to let this package use the same name--thanks!)
Use the Julia package manager. Within Julia, do:
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 at ReadTheDocs for examples of this and other features.