How would you write it with python generator?<br><br>And yet another solution:<br>dot(L1,L2) -><br>    {R, _} = lists:foldl(fun(X, {Acc, [Y|YT]}) -> {Acc + X*Y, YT} end, {0, L2}, L1),<br>    R.<br><br><div><span class="gmail_quote">
On 7/31/07, <b class="gmail_sendername">Ryan Rawson</b> <<a href="mailto:ryanobjc@gmail.com">ryanobjc@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
This is why language features > libraries generally. The compiler<br>knows nothing, so it has limited optimization abilities.<br><br>On a side note, most optimization strategies involve obtaining more<br>info. Type system, pragmas, explicit syntax support, etc. Its cool
<br>stuff.<br><br>-ryan<br><br><br>On Jul 30, 2007, at 2:27 PM, "James Hague" <<a href="mailto:james.hague@gmail.com">james.hague@gmail.com</a>><br>wrote:<br><br>>> But the problem is that these abstractions, or
<br>>> at least the combination of them, are slower than a hand-coded<br>>> function explicit recursion function. So, is there any way to make<br>>> the<br>>> natural abstractions work as fast as the hand-coded version?
<br>><br>> It's interesting that list comprehensions are compiled into code that<br>> acts the same as hand-coded functions, but uses of similar functions<br>> like lists:foldl, lists:flatmap, and lists:partition are not.
<br>><br>> James<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">
http://www.erlang.org/mailman/listinfo/erlang-questions</a><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">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote></div><br>