[Haskell-cafe] Multiple State Monads
pbeadling at mail2web.com
Thu Jan 15 20:41:25 EST 2009
On 16/01/2009 01:28, "Luke Palmer" <lrpalmer at gmail.com> wrote:
>> Compile-time constants could be handled by simple top-level bindings. This
>> technique is specifically for the case you are after:
>> mcSimulate :: Double -> Double -> Word64 -> [Double]
>> mcSimulate startStock endTime seedForSeed = go seedForSeed
>> go = fst expiryStock : go newSeedForSeed
>> expiryStock = iterate evolveUnderlying (startStock, ranq1Init
>> !! truncate (endTime/timeStep)
>> newSeedForSeed = seedForSeed + 246524
>> See what's going on there?
>> I don't know about that nested where. In Real Life I would probably use a
>> let instead for expiryStock and newSeedForSeed.
>> Ahh, I get it now, that¹s pretty neat - go¹ is only updating the seedForSeed
>> and the expiryStock, the inner where¹ clause keeps everything else constant
>> each time it is called.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe