[erlang-questions] A function as an element of a list of action

Micheus <>
Fri Jan 25 17:43:30 CET 2013


Hi there,

I did a google search but I couldn't find anything appropriated or I didn't
know how to ask about that.

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".
These functions will receive the same parameters.

I have an list of "fields" that tell me what I need to do (function to call) .
What I'm looking for is something like this:
+----------------------------------------------------------------------------------------+
 :
Lf=[{density,{true,Value}}, {ws,{trueValue}}, {hs,{trueValue}}, ...
,{he,{trueValue}}],
 :
Lc=lists:foldl(
    fun({density,{true,Value}}, Dict) ->
          Dict0=dict:store(top, calc_top/1, Dict);
          Dict1=dict:store(bottom, calc_bottom/1, Dict0);
          dict:store(side, calc_side/1, Dict1);
       ({bf,{true,Value}}, Acc) ->
          Dict0=dict:store(bottom, calc_bottom/1, Dict);
          dict:store(side, calc_side/1, Dict1);
       ({sf,{true,Value}}, Acc) ->
          dict:store(side, calc_side/1, Dict);
         :
       (_, Dict) -> Dict
dict:new(), Lf),

dict:fold(_Key, Func, Params0) ->
       Func(Params0)
Params, Lc),
 :
+----------------------------------------------------------------------------------------+

Does someone can help me?

TIA
Micheus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130125/6d60d861/attachment.html>


More information about the erlang-questions mailing list