     swap [ { } make ] dip <group> ; inline
 
 M: group intersect-scene ( hit ray group -- hit )
-    [
-        drop
-        objs>> [ [ tuck ] dip intersect-scene swap ] each
-        drop
-    ] if-ray-sphere ;
+    [ drop objs>> [ intersect-scene ] with each ] if-ray-sphere ;
 
-: initial-hit T{ hit f F{ 0.0 0.0 0.0 } 1.0/0.0 } ; inline
+: initial-hit T{ hit f F{ 0.0 0.0 0.0 } 1/0. } ; inline
 
 : initial-intersect ( ray scene -- hit )
-    initial-hit -rot intersect-scene ; inline
+    [ initial-hit ] 2dip intersect-scene ; inline
 
 : ray-o ( ray hit -- o )
-    over dir>> over lambda>> v*n
-    swap normal>> delta v*n v+
-    swap orig>> v+ ; inline
+    [ [ orig>> ] [ normal>> delta v*n ] bi* ]
+    [ [ dir>> ] [ lambda>> ] bi* v*n ]
+    2bi v+ v+ ; inline
 
 : sray-intersect ( ray scene hit -- ray )
     swap [ ray-o light vneg <ray> ] dip initial-intersect ; inline


USING: arrays accessors float-arrays io io.files
io.encodings.binary kernel math math.functions math.vectors
math.parser make sequences sequences.private words ;
IN: benchmark.raytracer

! parameters

: ray-g ( hit -- g ) normal>> light v. ; inline

: cast-ray ( ray scene -- g )
    2dup initial-intersect dup lambda>> 1/0. = [
        3drop 0.0
    ] [
        [ sray-intersect lambda>> 1/0. = ] keep swap
        [ ray-g neg ] [ drop 0.0 ] if
    ] if ; inline

