Re: Mathematica daily WTF (programming everything functionally?)

*To*: mathgroup at smc.vnet.net*Subject*: [mg115198] Re: Mathematica daily WTF (programming everything functionally?)*From*: Richard Fateman <fateman at cs.berkeley.edu>*Date*: Tue, 4 Jan 2011 04:24:26 -0500 (EST)*References*: <ifs32n$oqj$1@smc.vnet.net>

On 1/3/2011 12:57 AM, Andrzej Kozlowski wrote: > In any case, I cannot think of any scientific or mathematical problems that can be more naturally formulated in terms of "side-effects" than in terms of "functions". Perhaps they exist and I my bias is due to several decades of doing mathematics but I seriously can't think of a single example. Can you provide one? > Surely this argument has been expressed by proponents of purely functional programming languages, for which they have provided mechanisms to get over the difficulties. OK, here is a problem: simulate a stock market, where you have 1000 stocks with prices. Every time step your program surveys 100,000 traders who wish to buy or sell some number of shares of one of the stocks at some price. When you find a match, namely compatible sell/buy price and compatible number of shares, update the ownership of the 100,000 traders to reflect the transaction. Do this forever, periodically taking a snapshot/ backup of the situation, and logging all transactions as they occur. I think AES had other examples in mind, simulating dynamical systems or something.