I think (though I'm not sure) I understand what you're trying to do.<br>If I'm completely off track, perhaps you could be more concrete in your example - especially wrt. what the output should be?<br><br>If I understand correctly,<br>
- having Lc be a dict is a bad idea - if you want to preserve the order of the commands. Use a list instead:<br><br><div style="margin-left:40px">Lc = lists:map(fun(<span style="font-family:courier new,monospace">{density,{true,Value}}, Dict) -></span> ... end, Lf)<br>
</div><br>- You don't use Value. Where should it be used? I presume it should somehow be part of the context of the inner funs.<br><br>I think what you want could be something like:<br><div style="margin-left:40px"><span style="font-family:courier new,monospace">Lc = % List of command functions<br>
lists:map(fun({density,{true,Value}}, Dict) -><br> [fun(Dict) -><br> </span><span style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> </span>Dict0=dict:store(top, calc_top(Value), Dict);<br>
</span><span style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> </span>Dict1=dict:store(bottom, calc_bottom(Value), Dict0);<br> </span><span style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> </span>dict:store(side, calc_side(Value, Dict1)<br>
end];<br> ...<br> end,<br> Lf),<br>...<br>lists:foldl(fun(F,P) -> F(P) end, Params0, Lc)</span><br></div><br>(Not tested!)<br>Hoping this helps (which depends heavily of how well I understood your problem),<br>
/Erik<br><br><div class="gmail_quote">2013/1/25 Micheus <span dir="ltr"><<a href="mailto:micheus@gmail.com" target="_blank">micheus@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span style="font-family:courier new,monospace">Hi there,<br><br>I did a google search but I couldn't find anything appropriated or I didn't know how to ask about that.<br><br>I
would like to generate a list (based in some criterias - so, it can be
variable) in which each element is an function to be called posteriorly.
Something like a "script".<br>These functions will receive the same parameters.<br><br>I have an list of "fields" that tell me what I need to do (function to call)</span>
<span style="font-family:courier new,monospace">. What I'm looking for is something like this:<br>+----------------------------------------------------------------------------------------+<br> :<br>Lf=[{density,{true,Value}}, {ws,{trueValue}}, {hs,{trueValue}}, ... ,{he,{trueValue}}],<br>
:<br>Lc=lists:foldl(<br> fun({density,{true,Value}}, Dict) -><br> Dict0=dict:store(top, calc_top/1, Dict);<br> Dict1=dict:store(bottom, calc_bottom/1, Dict0);<br> dict:store(side, calc_side/1, Dict1);<br>
({bf,{true,Value}}, Acc) -><br> Dict0=dict:store(bottom, calc_bottom/1, Dict);<br> dict:store(side, calc_side/1, Dict1);<br> ({sf,{true,Value}}, Acc) -><br> dict:store(side, calc_side/1, Dict);<br>
:<br><span> (_, Dict) -> Dict<br>dict:new()</span>, Lf),<br><br>dict:fold(_Key, Func, Params0) -><br> Func(Params0)<br>Params, Lc),<br> :<br>+----------------------------------------------------------------------------------------+<br>
</span><br>Does someone can help me?<br><br>TIA<span class="HOEnZb"><font color="#888888"><br>Micheus<br>
</font></span><br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">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>