[Haskell-cafe] Multiple State Monads
Phil
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
>> where
>> go = fst expiryStock : go newSeedForSeed
>> where
>> expiryStock = iterate evolveUnderlying (startStock, ranq1Init
>> seedForSeed)
>> !! 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.
>>
>> Luke
>>
>> 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.
Thanks again!
Phil.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090116/bf070b81/attachment.htm
More information about the Haskell-Cafe
mailing list