Kyle Miller (Jan 31 2021 at 23:48):
Mostly for the fun of it, I followed the Ray Tracing in One Weekend book but in Lean rather than C++. It was overall a pleasant experience -- Lean is a nicely designed functional language!
My code isn't particularly fast (and I wasn't particularly focused on performance), but at least it's easily parallelized.
In case it's interesting, here's the code along with a rendered test image: https://github.com/kmill/lean4-raytracer
Bryan Gin-ge Chen (Feb 07 2021 at 05:55):
Reed Mullanix (Feb 07 2021 at 05:57):
The other one is _much_ better than mine! I do like how I implemented images, but beyond that their code doesn't have this abomination:
partial def UInt8.ofFloat (x : Float) : UInt8 := if x >= 255 then 255 else if x < 0 then 0 else go 0 255 where go (lo : Nat) (hi : Nat) : UInt8 := let mid := (lo + hi)/2 if hi <= lo then (UInt8.ofNat $ lo - 1) else if x < (Float.ofNat mid) then go lo mid else go (mid + 1) hi
Leonardo de Moura (Feb 07 2021 at 22:30):
@Reed Mullanix We have added the following coercions
Last updated: May 07 2021 at 13:21 UTC