Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lightning Talk B3: Pattern Matching #49

Open
geshuming opened this issue Mar 19, 2020 · 0 comments
Open

Lightning Talk B3: Pattern Matching #49

geshuming opened this issue Mar 19, 2020 · 0 comments

Comments

@geshuming
Copy link
Contributor

Link to the slides

WIIFY

Understanding pattern matching will boost code quality for functional languages, as well as effectively utilize one of the most popular string processing language RegEx.

Key Points

What is pattern matching?

Pattern matching is simply the matching of constructs to a specific pattern.

# fib(1) matches this clause
def fib(1), do: 1
# fib(2) matches this clause
def fib(2), do: 1
# everything else matches this clause
def fib(n), do: fib(n-1) + fib(n-2)

Use cases

As above, understanding pattern matching allows developers to create more concise code. We can also use pattern matching to destructure constructs.

%{name: name} = %{name: "AwesomeName", age: "18"}
# name is now bound to "AwesoneName"

RegEx also utilizes pattern matching to search for patterns in a String.

Pitfalls

Pattern matching constructs are mainly used in functional languages such as Elixir, Haskell.

Pattern matching in RegEx can become extremely complex.

Impact

Consider using functional languages to develop algorithms, create functional code.

Understanding pattern matching can also boost productivity in RegEx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant