<html>

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:Arial;}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
p
        {margin-right:0in;
        margin-left:0in;
        font-size:10.0pt;
        font-family:Arial;}
span.Typed
        {font-family:"Courier New";}
span.tty
        {font-family:"Courier New";}
span.Name
        {font-style:italic;}
span.Variable
        {font-family:"Times New Roman";
        font-style:italic;}
span.EmailStyle25
        {font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=blue>

<div class=Section1>

<p class=MsoNormal><span style='color:navy'>Let’s take a look at the
tuple:</span></p>

<p style='margin-left:22.5pt'><span style='font-family:Consolas;color:navy'>{person,{name,{first,joe},{last,armstrong}},{footsize,42}}.</span></p>

<p class=MsoNormal><span style='color:navy'>The last name is the second element
of a 2-tuple, whose first element is the atom “last”, so we would match
that with:</span></p>

<p style='margin-left:22.5pt'><span style='font-family:Consolas;color:navy'>{last,Last}</span></p>

<p class=MsoNormal><span style='color:navy'>or since we don’t care about
the first element:</span></p>

<p style='margin-left:22.5pt'><span style='font-family:Consolas;color:navy'>{_,Last}</span></p>

<p class=MsoNormal><span style='color:navy'>That tuple, however, is the third
element of a 3-tuple, so that is matched thus:</span></p>

<p style='margin-left:22.5pt'><span style='font-family:Consolas;color:navy'>{_,_,{_,Last}}</span></p>

<p class=MsoNormal><span style='color:navy'>Finally, that tuple is the second
element of a 3-tuple, resulting in the final match expression:</span></p>

<p style='margin-left:22.5pt'><span style='font-family:Consolas;color:navy'>{_,{_,_,{_,Last}},_}</span></p>

<p class=MsoNormal><span style='color:navy'>DBM</span></p>

<p class=MsoNormal><span style='color:navy'> </span></p>

<p class=MsoNormal><span style='color:navy'> </span></p>

<p class=MsoNormal><span style='color:navy'> </span></p>

<div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'>

<div>

<div class=MsoNormal align=center style='text-align:center'>

<hr size=2 width="100%" align=center tabindex=-1>

</div>

<p class=MsoNormal><b><span style='font-family:Tahoma'>From:</span></b><span
style='font-family:Tahoma'> erlang-questions-bounces@erlang.org
[mailto:erlang-questions-bounces@erlang.org] <b>On Behalf Of </b>Caitlin
Gibbons<br>
<b>Sent:</b> Wednesday, June 18, 2008 14:05<br>
<b>To:</b> erlang-questions@erlang.org<br>
<b>Subject:</b> Re: [erlang-questions] Help with tuple pattern match?</span></p>

</div>

<p class=MsoNormal> </p>

<p>Hi David.</p>

<p>Thanks for the prompt reply. Could you explain the details of your answer? I
interpreted the structure of this form of pattern matching as:</p>

<p>Person={person,{name,{first,joe},{last,armstrong}},{footsize,42}}.</p>

<p>{person,_,{name,_{first,_{last,_}},{footsize,_}=Person.</p>

<p>Is this correct? From left to right, one counts the atoms, i.e.,
person,name,first,last,etc. and 'aligns' them with the underscores?</p>

<p>Thanks again,</p>

<p>Caitlin</p>

<p> </p>

<p> </p>

<p class=MsoNormal> </p>

<div>

<p class=MsoNormal><span class=gmailquote>On 6/18/08, <b>David Mercer</b> <<a
href="mailto:dmercer@gmail.com">dmercer@gmail.com</a>> wrote:</span></p>

<div link=blue vlink=purple>

<div>

<p><span style='font-family:Consolas;color:navy'>1>
Person={person,{name,{first,joe},{last,armstrong}},{footsize,42}}.</span></p>

<p><span style='font-family:Consolas;color:navy'>{person,{name,{first,joe},{last,armstrong}},{footsize,42}}</span></p>

<p><span style='font-family:Consolas;color:navy'>2> {_,{_,_,{_,Last}},_} =
Person.</span></p>

<p><span style='font-family:Consolas;color:navy'>{person,{name,{first,joe},{last,armstrong}},{footsize,42}}</span></p>

<p><span style='font-family:Consolas;color:navy'>3> Last.</span></p>

<p><span style='font-family:Consolas;color:navy'>armstrong</span></p>

<p><span style='color:navy'> </span></p>

<div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'>

<div>

<div class=MsoNormal align=center style='text-align:center'>

<hr size=2 width="100%" align=center>

</div>

<p><b><span style='font-family:Tahoma'>From:</span></b><span style='font-family:
Tahoma'> <a href="mailto:erlang-questions-bounces@erlang.org" target="_blank">erlang-questions-bounces@erlang.org</a>
[mailto:<a href="mailto:erlang-questions-bounces@erlang.org" target="_blank">erlang-questions-bounces@erlang.org</a>]
<b>On Behalf Of </b>Caitlin Gibbons<br>
<b>Sent:</b> Wednesday, June 18, 2008 13:37<br>
<b>To:</b> <a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<b>Subject:</b> [erlang-questions] Help with tuple pattern match?</span></p>

</div>

<div><span id="q_11a9cfc51d5ace31_5">

<p> </p>

<p style='margin-bottom:12.0pt'>Hi all.<br>
<br>
I'm looking at:<br>
<br>
Person={person,{name,{first,joe},{last,armstrong}},{footsize,42}}.<br>
<br>
and trying to extract the value of 'last', i.e., 'armstrong'.<br>
<br>
{_,{_,{_,{_,Last},_}=Person.<br>
<br>
was unsuccessful. Any help?<br>
<br>
Thanks,<br>
<br>
Caitlin</p>

</div>

</div>

</div>

</div>

</div>

</span>

<p class=MsoNormal> </p>

</div>

</div>

</body>

</html>