Skip to content

Interface to match with a list of patterns #23

Open
@MasonProtter

Description

@MasonProtter

Currently, it seems the only API to use pattern matching with this package is with the provided macros. However, sometimes I want to generate a list of patterns and then do pattern matching using those instead of manually writing out all my patterns inside the macro.

It'd be really great if there was an API to do something like this:

const global_pats = [:(_::String   => :string)
                     :([a,a,a]     => (:all_the_same, a))
                     :([a,bs...,c] => (:at_least_2, a, bs, c))]

f(x) = match(x, global_pats)

julia> f("foo")
:string

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions