[erlang-questions] Idiom for multiple case matches

mats cronqvist masse@REDACTED
Fri Nov 7 20:40:29 CET 2008


"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



More information about the erlang-questions mailing list