[erlang-questions] Help with tuple pattern match?

Caitlin Gibbons <>
Wed Jun 18 21:04:59 CEST 2008

```Hi David.

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

Person={person,{name,{first,joe},{last,armstrong}},{footsize,42}}.

{person,_,{name,_{first,_{last,_}},{footsize,_}=Person.

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

Thanks again,

Caitlin

On 6/18/08, David Mercer <> wrote:
>
>  1> Person={person,{name,{first,joe},{last,armstrong}},{footsize,42}}.
>
> {person,{name,{first,joe},{last,armstrong}},{footsize,42}}
>
> 2> {_,{_,_,{_,Last}},_} = Person.
>
> {person,{name,{first,joe},{last,armstrong}},{footsize,42}}
>
> 3> Last.
>
> armstrong
>
>
>   ------------------------------
>
> *From:*  [mailto:
> ] *On Behalf Of *Caitlin Gibbons
> *Sent:* Wednesday, June 18, 2008 13:37
> *To:*
> *Subject:* [erlang-questions] Help with tuple pattern match?
>
>
>
> Hi all.
>
> I'm looking at:
>
> Person={person,{name,{first,joe},{last,armstrong}},{footsize,42}}.
>
> and trying to extract the value of 'last', i.e., 'armstrong'.
>
> {_,{_,{_,{_,Last},_}=Person.
>
> was unsuccessful. Any help?
>
> Thanks,
>
> Caitlin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080618/8126fccd/attachment.html>
```