When covering the help function
dbg:fun2ms/1, we went into a high-level
explanation of its results, namely match specifications. The
specifications are tuples with three elements of the format
[Head, Conditions, Body]:
The head is used to bind and match variables and terms.
In the conditions, logical tests are applied on the variables. You can define your own logical tests or use predefined guards.
In the body part of the specification, we list a possibly empty set of predefined actions that have to be taken if the match in the head is successful and the logical conditions are met.
The objective of this section is to ensure that you understand the
match specifications that result from the
ets:fun2ms/1 calls, and possibly implement some
simpler ones for yourself.
The head is a list of variables, literals, and composite data types. All
variables in the head are of the form
int() is replaced by an integer of the format
'1', ranging from 0 to 100,000,000. The atom
'_' denotes the “don’t care”
variable, and can be used if you are not interested in matching parts of
a particular argument. If you instead want to match on all values and
all arities without any variable bindings, you just use
'_', giving a specification of the form
['_', Conditions, Body]. You might be
tempted to write
Body] instead, but beware, as this will only match functions
of arity 0.
In the following example, we create ...