[erlang-questions] Re: Using match in guards
caio ariede
caio.ariede@REDACTED
Tue Dec 22 12:58:10 CET 2009
Thanks for all replies, but I needed something *in guards*. (not S = {regex, _})
Is a very strict behavior, so just element(1, S) == regex _sugested by
Dale Harvey_, did the trick.
search(S) when element(1, S) == regex -> ...
Caio Ariede
http://caioariede.com/
On Tue, Dec 22, 2009 at 6:51 AM, Bengt Kleberg
<bengt.kleberg@REDACTED> wrote:
> Greetings,
>
> It makes more sense (and works in the Erlang shell) to write the match
> in this order:
>
> {regex, _} = S
>
>
> bengt
>
> On Tue, 2009-12-22 at 09:45 +0100, Angel Alvarez wrote:
>> El Martes, 22 de Diciembre de 2009 00:02:55 caio ariede escribió:
>> > Just correcting my example:
>> >
>> > search(S) when S = {regex, _} ->
>>
>> PAttern matching?
>>
>> search(S={regex,_}) -> ....
>>
>>
>> /Angel
>>
>>
>>
>> > ...
>> >
>> > Caio Ariede
>> > http://caioariede.com/
>> >
>> >
>> >
>> > On Mon, Dec 21, 2009 at 9:01 PM, caio ariede <caio.ariede@REDACTED> wrote:
>> > > In function guards we can use functions like is_string/1 and is_number/1.
>> > >
>> > > But I'm needing to check a generic type defined by {type, Value} but
>> > > *in guards* like this:
>> > >
>> > > search(S) when N = {regex, _} ->
>> > > ...
>> > >
>> > > I know that I can do that with search(S = {regex, _}), but my example
>> > > was only for representing the problem.
>> > >
>> > > The main question is: there is a way for using match in guards? Or
>> > > something like this?
>> > >
>> > > Caio Ariede
>> > > http://caioariede.com/
>> > >
>> >
>> > ________________________________________________________________
>> > erlang-questions mailing list. See http://www.erlang.org/faq.html
>> > erlang-questions (at) erlang.org
>> >
>> >
>>
>>
>>
>
>
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
>
>
More information about the erlang-questions
mailing list