Destructuring and Pattern Matching in various FP languages
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
01_languages
02_double_dispatch
03_visitor
session
.DS_Store
.gitignore
CodeJugalbandi-Destructuring-PatternMatching-HealthyCode#Apr2015.pdf
LICENSE
README.md

README.md

Destructuring and Pattern Matching

Destructuring and Pattern Matching in various FP languages.

  • Most functional programming languages provide some level of de-structuring. Destructuring gives you a short-hand way of naming and getting the innards of the structure.

  • The difference between destructuring and pattern matching is that in Pattern matching, we are not only matching on relative positions of elements in the data-structure, but also trying to dispatch to different definitions based on the value inside the data structure. This dispatch is a kind of conditional construct, while in destructuring there is nothing conditional about it. So, Pattern matching is about associating a definition with a particular set of inputs. So, for the same function, we can have many such definitions for inputs that we destructure on.

This is an elaboration of one of the melodies that Ryan Lemmer and myself prepared for the Code Jugalbandi - http://codejugalbandi.org. You can download this Jugalbandi CodeJugalbandi-Destructuring-PatternMatching-HealthyCode#Apr2015.pdf (it appeared in the Healthy Code Magazine in April 2015.