[erlang-questions] Idiom for multiple case matches

Ulf Wiger <>
Fri Nov 7 17:52:24 CET 2008


It's slower, true, but both are fairly fast*, and the lists:member/2
solution is also very concise.

* I ran a small benchmark. On the given machine, Robert's
solution took ca 0.05 usec/call, while Mats's solution took
ca 0.09 usec/call (on average, iterating 1000 over the set of
vowels "aeiouyAEIOUY"). Using the smaller set "aeiouy",
Robert's code still took 0.05 usec/call, while Mats's code
used 0.08 usec.

BR,
Ulf W

2008/11/7 Hynek Vychodil <>:
>
>
> On Fri, Nov 7, 2008 at 3:22 PM, mats cronqvist <> wrote:
>>
>> "Robert Virding" <> writes:
>>
>> > A reasonable way of doing it would be:
>> >
>> > case is_vowel(Char) of
>> >     true -> ... ;
>> >     false -> ...
>> > end
>>
>>
>> is_wovel(C) -> lists:member(C,"aeiouy").
>
> It is slower than Robert's solution. If performance is significant
> lists:member solution is worse.
>>
>>
>>  mats
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
>
> --
> --Hynek (Pichi) Vychodil
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list