[Haskell-cafe] Simple matrix

Bjorn Lisper lisper at it.kth.se
Thu Jun 22 02:12:48 EDT 2006


I wrote:
>Here is one way to do it. First, you have to interpret operations on
>matrices as being elementwise applied. E.g, (*) is interpreted as zipWith
>(zipWith (*)) rather than matrix multiply, and similar for (+) etc. You then
>obtain a lazy semantics for the operations, where the extent of the
>resulting matrix is the intersection of the extents of the argument
>matrices. Second, you lift constants into infinite matrices containing the
>constant, that is: fromInteger n = repeat (repeat n). Now your examples will
>work as intended.

Ah, should of course be fromInteger n = repeat (repeat (fromInteger n)).

Björn Lisper


More information about the Haskell-Cafe mailing list