<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>Something along the lines of</div><div><br></div><div>next(_, []) -></div><div>      ok;</div><div><br></div><div>next(Fun, [H|T]) -></div><div>      F = fun()</div><div>                Fun(T)</div><div>      end,</div><div>      Result = Fun(H),</div><div><br></div><div>      {Result, F}.</div><div><br></div><div><br></div><div><br></div><div><br></div><div>test() -></div><div>        Params = [[1], [1, 2], [1, 2, 3]],</div><div>        Start = next(fun erlang:length/1, Params),</div><div>        output(Start).</div><div><br></div><div><div>output(ok) -></div><div>      io:format("ok");</div><div><div><br></div><div>output({Result, F}) -></div><div>      io:format("~w", [Result]),</div><div><br></div><div>      NewResult = F(),</div><div>      output(NewResult).</div></div></div><div>    </div><div><br></div><div><br></div><div>?</div><div><br></div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">In a normal scenario, I would prefer serial code, admittedly.<div>However, the scenario that I want to implement is the following: I want to retry the same piece of code several times, each time with a different settings.  The ways to do so are either making sure that each step in the code is a function (i.e., CPS), or exploiting callcc.</div>
<div>Other ideas?</div><div><br></div><div>G.<br><br><div class="gmail_quote">On Wed, Jul 27, 2011 at 7:23 AM, Jon Watte <span dir="ltr"><<a href="mailto:jwatte@gmail.com">jwatte@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div>One of the biggest problems of CPS code in Twisted or Node or most other frameworks using that mechanism, is that it ends up with single-threaded servers, making poor use of multi-threaded hardware.</div>In Erlang, a process is comparable to the cost as a continuation with a function lambda in other languages (give or take a little bit, depending on specifics of implementation and use).</div>

<div>Write your code serially, in a process, and talk to it using messaging. It's easier to write, debug, and understand that way. Because of data being immutable, there is no risk of threading data hazards.</div><div>

 </div><div>Sincerely,</div><div> </div><div>jw<br clear="all"><br>--<br>Americans might object: there is no way we would sacrifice our living standards for the benefit of people in the rest of the world. Nevertheless, whether we get there willingly or not, we shall soon have lower consumption rates, because our present rates are unsustainable. <br>

<br>
<br><br></div><div class="gmail_quote"><div><div></div><div class="h5">On Tue, Jul 26, 2011 at 12:39 AM, Guy Wiener <span dir="ltr"><<a href="mailto:wiener.guy@gmail.com" target="_blank">wiener.guy@gmail.com</a>></span> wrote:<br>
</div></div><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204, 204, 204);border-left-width:1px;border-left-style:solid" class="gmail_quote"><div><div></div><div class="h5">
<div dir="ltr">Hello everyone,<div>Is there some equivalent to callcc (as in Scheme or Ruby) in Erlang?</div><div>Alt., is there some what to encourage Continuation-Passing Style programming in Erlang, other than just recommending that all consequent function calls will be in tail-call position?</div>


<div><br></div><div>Thanks,</div><div>  Guy</div></div>
<br></div></div>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br>
</blockquote></div><br></div></div>
_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>http://erlang.org/mailman/listinfo/erlang-questions<br></blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px; ">===================================</span></font></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px; ">Dmitrii Dimandt<br><a href="mailto:dmitrii@dmitriid.com">dmitrii@dmitriid.com</a><br><br></span></font></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px; ">------------------------------------------------------------<br>Erlang in Russian<br><a href="http://erlanger.ru/">http://erlanger.ru/</a></span></font><div><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px; "><br></span></font></div><div><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px; ">TurkeyTPS</span></font></div><div><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px; "><a href="http://turkeytps.com/">http://turkeytps.com/</a></span></font></div><div><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px; ">------------------------------------------------------------</span></font></div><div><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px; "><br></span></font></div><div><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px; ">LinkedIn: <a href="http://www.linkedin.com/in/dmitriid">http://www.linkedin.com/in/dmitriid</a></span></font></div><div><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px; ">GitHub: <a href="https://github.com/dmitriid">https://github.com/dmitriid</a></span></font></div><div><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px; "><br></span></font></div></div></span></div></span><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px; "><br class="Apple-interchange-newline"></span></font></div></span><br class="Apple-interchange-newline"></span><br class="Apple-interchange-newline">
</div>
<br></body></html>