<div dir="auto"><div>The argument order in the email is a typo, which is what Dmitry tried to point out.</div><div dir="auto"><br></div><div dir="auto"><a href="http://erlang.org/documentation/doc-10.0-rc1/lib/stdlib-3.5/doc/html/lists.html#search-2">http://erlang.org/documentation/doc-10.0-rc1/lib/stdlib-3.5/doc/html/lists.html#search-2</a></div><div dir="auto"><br></div><div dir="auto">It is lists:search(Pred, List).</div><div dir="auto"><br><div class="gmail_quote" dir="auto"><div dir="ltr">On Wed, 2 May 2018, 21:12 Alexander Petrovsky, <<a href="mailto:askjuise@gmail.com">askjuise@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div dir="auto">Totally agree with Frans Schneider, the arguments order in different modules in stdlib differs from one to another. And I think will be better reorder args in lists:search.</div><div dir="auto"><br></div><div dir="auto">For me much more close approach suggested by Chris Okasaki, short summary from SO (<a href="https://stackoverflow.com/questions/5863128/ordering-of-parameters-to-make-use-of-currying" target="_blank" rel="noreferrer">https://stackoverflow.com/questions/5863128/ordering-of-parameters-to-make-use-of-currying</a>):</div><div dir="auto"><br></div><div dir="auto"><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">For languages that support currying and partial-application easily, there is one compelling series of arguments, originally from Chris Okasaki:<ul style="margin:0px 0px 1em 30px;padding:0px;border:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-weight:400;font-stretch:inherit;line-height:inherit;font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;vertical-align:baseline;list-style:disc;box-sizing:inherit;color:rgb(36,39,41);letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><li style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;word-wrap:break-word"><strong style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:bold;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit">Put the data structure as the last argument</strong></li></ul>Why? You can then<span> </span><a href="http://www.haskell.org/pipermail/libraries/2005-August/004297.html" rel="noreferrer noreferrer" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-size:15px;vertical-align:baseline;box-sizing:inherit;color:rgb(0,89,153);text-decoration:none" target="_blank">compose operations on the data</a><span> </span>nicely. E.g.<span> </span><code style="margin:0px;padding:1px 5px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;background-color:rgb(239,240,241);white-space:pre-wrap">insert 1 $ insert 2 $ insert 3 $ s</code>. This also helps for<span> </span><a href="http://www.haskell.org/pipermail/libraries/2005-August/004323.html" rel="noreferrer noreferrer" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-size:15px;vertical-align:baseline;box-sizing:inherit;color:rgb(0,89,153);text-decoration:none" target="_blank">functions on state</a>.<br>Standard libraries such as "containers"<span> </span><a href="http://hackage.haskell.org/packages/archive/containers/0.4.0.0/doc/html/Data-Map.html#g:5" rel="noreferrer noreferrer" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-size:15px;vertical-align:baseline;box-sizing:inherit;color:rgb(0,89,153);text-decoration:none" target="_blank">follow this convention</a>.<br>Alternate arguments are sometimes given to put the data structure first, so it can be closed over, yielding functions on a static structure (e.g. lookup) that are a bit more concise. However, the broad consensus seems to be that this is less of a win, especially since it pushes you towards heavily parenthesized code.<ul style="margin:0px 0px 1em 30px;padding:0px;border:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-weight:400;font-stretch:inherit;line-height:inherit;font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;vertical-align:baseline;list-style:disc;box-sizing:inherit;color:rgb(36,39,41);letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><li style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;word-wrap:break-word"><strong style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:bold;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit">Put the most varying argument last</strong></li></ul>For recursive functions, it is common to put the argument that varies the most (e.g. an accumulator) as the last argument, while the argument that varies the least (e.g. a function argument) at the start. This composes well with the data structure last style.</blockquote><div><br></div><div>So, the</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">lists:search(fun/1, list) -> {ok, Value} | false</blockquote><div><br></div><div> will be more appropriate then</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">lists:search(list, fun/1) -> {ok, Value} | false</blockquote><div> </div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"></span></blockquote><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"></span></div><br><div class="gmail_quote"><div>ср, 2 мая 2018 г. в 16:10, Dmitry Klionsky <<a href="mailto:dm.klionsky@gmail.com" target="_blank" rel="noreferrer">dm.klionsky@gmail.com</a>>:<br></div></div></div><div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">No, it's fine.<br>
<br>
<a href="https://github.com/erlang/otp/blob/master/lib/stdlib/src/lists.erl#L1402-L1413" rel="noreferrer noreferrer" target="_blank">https://github.com/erlang/otp/blob/master/lib/stdlib/src/lists.erl#L1402-L1413</a><br>
<br>
<br>
On 05/02/2018 04:06 PM, Frans Schneider wrote:<br>
> Is the fun/1 really the second argument in the call lists:search/2?<br>
><br>
> lists:search(list,fun/1) -> {ok, Value} | false<br>
><br>
> Doesn't feel consistent with the other functions in the list module <br>
> which have the fun/1 as the first argument.<br>
><br>
> Cheers,<br>
><br>
> Frans<br>
><br>
> On 05/02/2018 01:37 PM, Henrik Nord X wrote:<br>
>> lists:search(list,fun/1) -> {ok, Value} | false<br>
> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org" target="_blank" rel="noreferrer">erlang-questions@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br>
-- <br>
BR,<br>
Dmitry<br>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank" rel="noreferrer">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div></div></div></div>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank" rel="noreferrer">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div></div></div>