# Library report examples

**Ian Lynagh
**
igloo@earth.li

*Mon, 26 Nov 2001 14:02:51 +0000*

Hi guys,
The library report defines
-- Diagonal of a square matrix
diag :: (Ix a) => Array (a,a) b -> Array a b
diag x = ixmap (l,u) (\i->(i,i)) x
where ((l,l'),(u,u')) | l == l' && u == u' = bounds x
but ghc, hugs and nhc98 all loop (trying to get and test the value of l
I believe).
I am also curious why, for example,
row :: (Ix a, Ix b) => a -> Array (a,b) c -> Array b c
row i x = ixmap (l',u') (\j->(i,j)) x where ((l,l'),(u,u')) = bounds x
isn't written as
row :: (Ix a, Ix b) => a -> Array (a,b) c -> Array b c
row i x = ixmap (l,u) (\j->(i,j)) x where ((_,l),(_,u)) = bounds x
~~~ ~~~ ~~~
Thanks
Ian