[erlang-questions] Idiom for multiple case matches

Hynek Vychodil vychodil.hynek@REDACTED
Fri Nov 7 23:21:50 CET 2008


Ok, I bring it back. For this short lists function lists:member is almost
same fast since lists:member is BIF. I didn't know it and I had not
measured. Sorry. I have benchmarked it now and there is not significant
difference in R12B-3 on my Intel Core2 Duo Debian Linux laptop.

On Fri, Nov 7, 2008 at 8:40 PM, mats cronqvist <masse@REDACTED> wrote:

> "Hynek Vychodil" <vychodil.hynek@REDACTED> writes:
>
> > On Fri, Nov 7, 2008 at 3:22 PM, mats cronqvist <masse@REDACTED>
> wrote:
> >
> >     "Robert Virding" <rvirding@REDACTED> 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.
>
>   is it? so you measured it, but decided to save internet bandwidth by
>  not posting the results. commendable. cause you surely wouldn't just
>  guess and make a fool of yourself?
>
> > If performance is significant lists:member solution is worse.
>
>   only if lists:member/1 come out near the top in your application CPU
>  time profiling.
>
>  now if you have an application where the CPU cost of sorting
>  characters according to wovelness is significant, you should
>  probably consider switching to C. otherwise, you should aim for code
>  that communicates intent.
>
>  mats
>



-- 
--Hynek (Pichi) Vychodil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081107/40c2efb1/attachment.htm>


More information about the erlang-questions mailing list