Ulf,<br><br>Isn't there also more garbage (as in GC) created by Mats' solution? Doesn't the list "aeiouy" get created and destroyed every time, or does the compiler "know" it is constant and make one constant copy of it that is not GC'ed?<br>
<br>Regards,<br>Edwin Fine<br><br><div class="gmail_quote">On Fri, Nov 7, 2008 at 11:52 AM, Ulf Wiger <span dir="ltr"><<a href="mailto:ulf@wiger.net">ulf@wiger.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
It's slower, true, but both are fairly fast*, and the lists:member/2<br>
solution is also very concise.<br>
<br>
* I ran a small benchmark. On the given machine, Robert's<br>
solution took ca 0.05 usec/call, while Mats's solution took<br>
ca 0.09 usec/call (on average, iterating 1000 over the set of<br>
vowels "aeiouyAEIOUY"). Using the smaller set "aeiouy",<br>
Robert's code still took 0.05 usec/call, while Mats's code<br>
used 0.08 usec.<br>
<br>
BR,<br>
Ulf W<br>
<br>
2008/11/7 Hynek Vychodil <<a href="mailto:vychodil.hynek@gmail.com">vychodil.hynek@gmail.com</a>>:<br>
<div><div></div><div class="Wj3C7c">><br>
><br>
> On Fri, Nov 7, 2008 at 3:22 PM, mats cronqvist <<a href="mailto:masse@kreditor.se">masse@kreditor.se</a>> wrote:<br>
>><br>
>> "Robert Virding" <<a href="mailto:rvirding@gmail.com">rvirding@gmail.com</a>> writes:<br>
>><br>
>> > A reasonable way of doing it would be:<br>
>> ><br>
>> > case is_vowel(Char) of<br>
>> > true -> ... ;<br>
>> > false -> ...<br>
>> > end<br>
>><br>
>><br>
>> is_wovel(C) -> lists:member(C,"aeiouy").<br>
><br>
> It is slower than Robert's solution. If performance is significant<br>
> lists:member solution is worse.<br>
>><br>
>><br>
>> mats<br>
>> _______________________________________________<br>
>> erlang-questions mailing list<br>
>> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
>> <a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
><br>
><br>
><br>
> --<br>
> --Hynek (Pichi) Vychodil<br>
><br>
> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
> <a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
><br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
<br>
</div></div></blockquote></div><br>