Deforesting binary tree operations?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Deforesting binary tree operations?

Neal Alexander-2
Is it possible to deforest something like this?



data Matrix a = Scalar a
               | Matrix (Matrix a,Matrix a,Matrix a,Matrix a)


(*) (Matrix (a11,a12,a21,a22)) (Matrix (b11,b12,b21,b22)) =

         Matrix ( (a11 * b11) + (a12 * b21),
                  (a11 * b12) + (a12 * b22),
                  (a21 * b11) + (a22 * b21),
                  (a21 * b12) + (a22 * b22) )

(*) (Scalar a) (Scalar b) = Scalar (a * b)