Philosophical aside #2: Generating and storing simulation data.

In a procedural language, we would tend to separate, at least in mind, the process of generating the events from the process of storing data about these events. For example, a piece of procedural pseudocode might read

for LOOP = 1 to 1000 do
begin
  Generate_Next_Event;
  Record_Result;
end;


Here, within each time-step of the process, separate procedures generate and store the events in the simulation. In the functional programming approach, this distinction disappears. Rather than loop through a procedure, storing the results one-by-one into a data structure, in the functional paradigm we simply generate the list of events, and subsequently extract the statistical information of interest.  In pseudocode,

history=Table[Single_Event,1000];
ReportStatistics[history];

Of course, the example above is almost laughably simple; among other things, subsequent events are not influenced by previous events. We will see, however, that a similar approach be taken for far more complicated processes; therein lies the power of the functional approach.


Converted by Mathematica      November 5, 1999