我怀疑光线跟踪器的顶部是什么.我非常喜欢我的Mandelbrot表达:
from row in Enumerable.Range(0, ImageHeight) from col in Enumerable.Range(0, ImageWidth) // Work out the initial complex value from the row and column let c = new Complex((col * SampleWidth) / ImageWidth + OffsetX, (row * SampleHeight) / ImageHeight + OffsetY) // Work out the number of iterations select Generate(c, x => x * x + c).TakeWhile(x => x.SquareLength < 4) .Take(MaxIterations) .Count() into count // Map that to an appropriate byte value select (byte)(count == MaxIterations ? 0 : (count % 255) + 1);
Mads Torgersen演示了如何在LINQ中编写一个自包含的递归lambda表达式来计算(例如)一个阶乘:
i => new Func,Func >(fac => x => x == 0 ? 1 : x * fac(x - 1))(new SelfApplicable ,Func >,Func >>(y => f => x => f(y(y)(f))(x))(y => f => x => f(y(y)(f))(x))(fac => x => x == 0 ? 1 : x * fac(x - 1)))(i)
Mads指出:
我甚至无法弄清楚如何打破它以使其接近可读,所以我没有.