2008/5/12 Lauri Oksanen <[EMAIL PROTECTED]>:
> Hi,
>
> I'm writing my first real Haskell program and I came up with the following
> code snippet.
>
> ---
> let x' = x \+ dist \* dir
> nx' = normal geometry
> wi = (-1) \* dir
> in do
> (p, wo) <- brdfCosSampling reflector nx' wi
> let color' = p \** color
> q = min 1 (scalarContribution p)
> in do
> sampler <- biasedCoinSampler q
> (radianceSampler surfaces x' wo (q \* color'))
> (terminalRadianceSampler surfaces x' nx' ((1-q) \*
> color'))
> sampler
Do-notation already offers what you want. Try this out:
do let x' = x \+ dist \* dir
nx' = normal geometry
wi = (-1) \* dir
(p, wo) <- brdfCosSampling reflector nx' wi
let color' = p \** color
q = min 1 (scalarContribution p)
sampler <- biasedCoinSampler q
(radianceSampler surfaces x' wo (q \* color'))
(terminalRadianceSampler surfaces x' nx'
((1-q) \* color'))
sampler
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe